Module:Storm categories
![]() | This module is rated as ready for general use. It has reached a mature form and is thought to be relatively bug-free and ready for use wherever appropriate. It is ready to mention on help pages and other Wikipedia resources as an option for new users to learn. To reduce server load and bad output, it should be improved by sandbox testing rather than repeated trial-and-error editing. |
![]() | This module is subject to page protection. It is a highly visible module in use by a very large number of pages, or is substituted very frequently. Because vandalism or mistakes would affect many pages, and even trivial editing might cause substantial load on the servers, it is protected from editing. |
![]() | This Lua module is used on approximately 5,600 pages and changes may be widely noticed. Test changes in the module's /sandbox or /testcases subpages, or in your own module sandbox. Consider discussing changes on the talk page before implementing them. |
![]() | In order to conform to Wikipedia:Manual of Style/Accessibility#Color guidelines, do not use storm colors in conjunction with links. This is necessary to avoid problems related to lack of contrast. |
![]() | This module depends on the following other modules: |
This template is used to control a multitude of tropical cyclone-related templates: {{storm colour}}, {{storm name}}, and {{storm icon}}. It acts as a centralized location for storm categories to avoid discrepancies between templates, allowing for the same ID to be used across all related templates.
Data is located in the following submodules:
- Module:Storm categories/categories for fully-detailed storm categories
- Module:Storm categories/colors for color-only IDs
- Module:Storm categories/icons for icon-only IDs
Usage
This module exports three functions for templates: p.color
, p.name
, p.sortkey
, and p.icon
. It also provides p._color
, p._name
, p._sortkey
, and p._icon
for use in other modules.
All input IDs are case-insensitive, and all non-alphanumeric characters are stripped.
Color
Provides the color of the given tropical cyclone category code. This comes in the format of their raw hexadecimal code. This function is available as a template at {{storm colour}}.
Code | Output |
---|---|
<span style="padding:4px;border:1px solid black;background-color:#{{#invoke:Storm categories|color|depression}}">depression</span>
|
<span style="padding:4px;border:1px solid black;background-color:#Lua error at line 276: bad argument #1 to 'lower' (string expected, got table).">depression |
Name
Provides the name of the given tropical cyclone category code. A optional basin argument can be provided as the second argument in order to slightly tweak the name of the category, if the given category definition supports it. This function is available as a template at {{storm name}}.
Code | Interpreted | Output | |
---|---|---|---|
ID | Basin | ||
{{#invoke:Storm categories|name|severe}}
|
severe | (default) | Lua error at line 281: bad argument #1 to 'lower' (string expected, got table). |
{{#invoke:Storm categories|name|spr - cYcL -s TorM}}
|
sprcyclstorm | (default) | Lua error at line 281: bad argument #1 to 'lower' (string expected, got table). |
{{#invoke:Storm categories|name|cat5}}
|
cat5 | (default) | Lua error at line 281: bad argument #1 to 'lower' (string expected, got table). |
{{#invoke:Storm categories|name|cat5|ATl}}
|
cat5 | ATl | Lua error at line 281: bad argument #1 to 'lower' (string expected, got table). |
{{#invoke:Storm categories|name|cat5|WPac}}
|
cat5 | WPac | Lua error at line 281: bad argument #1 to 'lower' (string expected, got table). |
Sortkey
The sortkey is a number that aids in sorting categories. Using the sortkey, it is possible to automatically sort a table of tropical cyclones given their category code. Due to the ambiguous nature of sortkeys, tables may be sorted incorrectly if values from other basins were used. For categories that span multiple basins, however, (e.g. depression
and storm
) they are given the lowest possible sortkeys in order to achieve maximum compatibility.
This sortkey is used in {{Tropical cyclone season effects (cyclone)}}, a subtemplate of {{Tropical cyclone season effects}}.
The sortkey format is as follows. Note that not all values between the given ranges were used. The arrangement of these were determined by their positions in the {{Storm colour}} template.
Basin | Sortkey range |
---|---|
Global (unused) | 90000 to 99999 |
Atl/EPac/SAtl | 80000 to 89999 |
WPac | 60000 to 69999 |
Nio | 50000 to 59999 |
Aus/Fiji | 40000 to 49999 |
SWio | 30000 to 39999 |
Historical | 20000 to 29999 |
Global | 0 to 9999 |
A demonstration of a sortable table using these sortkeys can be found below. Note that it does not use categories outside of its own basin (in this case, the Atl/EPac/SAtl basin) and the global range.
Category | Sortkey | Code |
---|---|---|
cat3 | Error in Template:Nts: Fractions are not supported | {{#invoke:Storm categories|sortkey|cat3}}
|
cat1 | Error in Template:Nts: Fractions are not supported | {{#invoke:Storm categories|sortkey|cat1}}
|
cat5 | Error in Template:Nts: Fractions are not supported | {{#invoke:Storm categories|sortkey|cat5}}
|
cat4 | Error in Template:Nts: Fractions are not supported | {{#invoke:Storm categories|sortkey|cat4}}
|
depression | Error in Template:Nts: Fractions are not supported | {{#invoke:Storm categories|sortkey|depression}}
|
cat2 | Error in Template:Nts: Fractions are not supported | {{#invoke:Storm categories|sortkey|cat2}}
|
Sorting table which uses different basins
| ||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
Icon
Icons exist for some Storm categories for presentation purposes. This function is available as a template at {{storm icon}}. p.icon
will return wikitext of an image or formatted text.
Full list of available values
The following table is generated by invoking the demo
function of this module. Some IDs are only available as colors or icons because they existed as parameters on old non-module template implementations and cannot be feasibly aliased to a specific tropical cyclone category.
It will show any color errors, including colors which aren't compliant with the minimal Web Content Accessibility Guidelines 2.0 AA color standards (see MOS:COLOR for more information). Script error: The function "demo" does not exist.
local p = {}
-- Define categories
local defs = {
extratropical = {
color = "cccccc",
name = "Extratropical cyclone",
sortkey = 120
},
storm = {
color = "00faf4",
name = "Tropical storm",
sortkey = 100
},
depression = {
color = "5ebaff",
name = "Tropical depression",
sortkey = 90
},
disturbance = {
color = "80ccff",
name = "Tropical disturbance",
sortkey = 80
},
subtropical = {
color = "00faf4",
name = "Subtropical storm",
sortkey = 50
},
subdepression = {
color = "00faf4",
name = "Subtropical depression",
sortkey = 45
},
subdisturbance = {
color = "00faf4",
name = "Subtropical disturbance",
sortkey = 40
},
monsoondepression = {
color = "5ebaff",
name = "Monsoon depression",
sortkey = 30
},
potential = {
color = "80ccff",
name = "Potential tropical depression",
sortkey = 25
},
posttropical = {
color = "cccccc",
name = "Post-tropical depression",
sortkey = 70
},
remnant = {
color = "cccccc",
name = "Post-tropical depression",
sortkey = 70
},
unknown = {
color = "c0c0c0",
name = "Unknown strength tropical cyclone",
sortkey = 0
},
cat5 = {
color = "ff6060",
name = "Category 5 %s",
sortkey = 10010
},
cat4 = {
color = "ff8f20",
name = "Category 4 %s",
sortkey = 10008
},
cat3 = {
color = "ffc140",
name = "Category 3 %s",
sortkey = 10006
},
cat2 = {
color = "ffe775",
name = "Category 2 %s",
sortkey = 10004
},
cat1 = {
color = "ffffcc",
name = "Category 1 %s",
sortkey = 10002
},
supertyphoon = {
color = "ff6060",
name = "Category 4 super typhoon",
sortkey = 10015
},
typhoon = {
color = "fdaf9a",
name = "Typhoon",
sortkey = 20010
},
nwpsevere = {
color = "ccffff",
name = "Severe tropical storm",
sortkey = 20008
},
sprcyclstorm = {
color = "ff6060",
name = "Super cyclonic storm",
sortkey = 30020
},
esvrcyclstorm = {
color = "ff6060",
name = "Extremely severe cyclonic storm",
sortkey = 30015
},
vsvrcyclstorm = {
color = "ff6060",
name = "Very severe cyclonic storm",
sortkey = 30010
},
svrcyclstorm = {
color = "ccffff",
name = "Severe cyclonic storm",
sortkey = 30008
},
niocyclone = {
color = "00faf4",
name = "Cyclonic storm",
sortkey = 30006
},
deepdepression = {
color = "5ebaff",
name = "Deep depression",
sortkey = 30002
},
nioland = {
color = "80ccff",
name = "Land depression",
sortkey = 30000
},
Aus5 = {
color = "ff6060",
name = "Category 5 severe tropical cyclone",
sortkey = 40010
},
Aus4 = {
color = "ffc140",
name = "Category 4 severe tropical cyclone",
sortkey = 40010
},
Aus3 = {
color = "ffffcc",
name = "Category 3 severe tropical cyclone",
sortkey = 40010
},
Aus2 = {
color = "ccffff",
name = "Category 2 tropical cyclone",
sortkey = 40010
},
Aus1 = {
color = "00faf4",
name = "Category 1 tropical cyclone",
sortkey = 40010
},
vintense = {
color = "ff6060",
name = "Very intense tropical cyclone",
sortkey = 50010
},
intense = {
color = "ffc140",
name = "Intense tropical cyclone",
sortkey = 50008
},
tropicalcyclone = {
color = "ffffcc",
name = "Tropical cyclone",
sortkey = 50006
},
mstorm = {
color = "00faf4",
name = "Moderate tropical storm"
},
ZODW = {
color = "80ccff",
name = "Zone of disturbed weather",
sortkey = 50000
},
shemsvrtc = {
color = "ffe775",
name = "Severe tropical cyclone",
sortkey = 60020
},
shem5 = {
color = "ff6060",
name = "Severe tropical cyclone",
sortkey = 60010
},
shem4 = {
color = "ffc140",
name = "Tropical cyclone",
sortkey = 60008
},
shem2 = {
color = "ccffff",
name = "Tropical cyclone",
sortkey = 60008
},
shem1 = {
color = "00faf4",
name = "Tropical cyclone",
sortkey = 60008
}
}
-- Default
local defaultCategory = "unknown"
-- Define aliases
-- All non-alphanumeric characters are already stripped, and the string is
-- already set to lowercase, so additional aliases for those are no longer
-- required.
defs["STY"] = defs["supertyphoon"]
defs["strong"] = defs["nwpsevere"]
defs["STS"] = defs["nwpsevere"]
defs["TY"] = defs["typhoon"]
defs["TD"] = defs["depression"]
defs["TS"] = defs["storm"]
defs["nwpstorm"] = defs["storm"]
defs["D"] = defs["depression"]
defs["spdepression"] = defs["depression"]
defs["niodepression"] = defs["depression"]
defs["shemdepression"] = defs["depression"]
defs["swiodepression"] = defs["depression"]
defs["spdepression"] = defs["depression"]
defs["nwpdepression"] = defs["depression"]
defs["subtropicalcyclone"] = defs["subtropical"]
defs["swsubdep"] = defs["subtropical"]
defs["SD"] = defs["subdepression"]
defs["SS"] = defs["subtropical"]
defs["MD"] = defs["monsoondepression"]
defs["PT"] = defs["potential"]
defs["post"] = defs["potential"]
defs["potentialtropicalcyclone"] = defs["potential"]
defs["potentialtropicalcyclone"] = defs["potential"]
defs["remnantlow"] = defs["remnant"]
defs["RL"] = defs["remnant"]
defs["swiosts"] = defs["nwpstorm"]
defs["SUCS"] = defs["sprcyclstorm"]
defs["ESCS"] = defs["esvrcyclstorm"]
defs["VSCS"] = defs["vsvrcyclstorm"]
defs["SCS"] = defs["svrcyclstorm"]
defs["CS"] = defs["niocyclone"]
defs["DD"] = defs["deepdepression"]
defs["cyclstorm"] = defs["niocyclone"]
defs["landdepression"] = defs["nioland"]
defs["land"] = defs["nioland"]
defs["Fiji5"] = defs["Aus5"]
defs["Fiji4"] = defs["Aus4"]
defs["Fiji3"] = defs["Aus3"]
defs["Fiji2"] = defs["Aus2"]
defs["Fiji1"] = defs["Aus1"]
defs["DI"] = defs["disturbance"]
defs["swiodisturbance"] = defs["disturbance"]
defs["MTS"] = defs["mstorm"]
defs["sub"] = defs["mstorm"]
defs["swiotc"] = defs["tropicalcyclone"]
defs["shem3"] = defs["tropicalcyclone"]
defs["shemtc"] = defs["tropicalcyclone"]
function p.color(category)
return defs[string.len(0) ~= 0 and string.lower(category).gsub("[^%w]", "") or defaultCategory].color
end
function p.name(category, basin)
return string.format(
defs[string.len(0) ~= 0 and string.lower(category).gsub("[^%w]", "") or defaultCategory].name,
-- Eventually replace with own module
(basin == "Atl" or basin == "EPac" or basin == "SAtl") and "hurricane" or
(basin == "WPac" and "typhooon" or "tropical cyclone")
)
end
function p.sortkey(category)
return defs[string.len(0) ~= 0 and string.lower(category).gsub("[^%w]", "") or defaultCategory].sortkey
end
return p