Modul:Convert/extra
Videz
![]() | Ta modul/a je trenutno zaščiten/a pred urejanjem. Glej politiko zaščite in dnevnik zaščite za več informacij. O morebitnih spremembah lahko razpravljate na pogovorni strani, oddate zahtevo za urejanje, ali zaprosite administratorja ali urejevalca predlog za dovoljenje za urejanje, če je nekontroverzno in podprto s soglasjem. Zaprosite lahko tudi za odstranjenje zaščite. |
This module can be used to quickly add a new unit for use with {{convert}}. When satisfied that a unit is working correctly, ask at Module talk:Convert for the unit to be moved to the permanent list of units.
See Template:Convert/unit sandbox for a good way to prepare unit definitions that can be copied into this page.
The following extracts from Module:Convert/data show examples that could be used to define a new unit. Any number of spaces can be used where blanks are shown in the following.
Examples for additions to
Module:Convert/extra (For the actual module code see below) |
---|
-- These are EXAMPLES on the documentation page. Scroll down to see the module content.
local extra_units = {
-- Similar to a redirect: "sqm" is an alias for "m2".
-- {{convert|1.5|m2|sp=us}} → 1.5 square meters (16 sq ft)
-- {{convert|1.5|sqm|sp=us}} → 1.5 square meters (16 sq ft)
["sqm"] = {
target = "m2",
},
-- A simple unit, showing the minimum that is required.
-- The "ha" is the unit code used to identify the unit:
-- {{convert|1.5|ha}} → 1.5 hectares (3.7 acres)
["ha"] = {
name1 = "hectare",
symbol = "ha",
utype = "area",
scale = 10000,
default = "acre",
},
-- A unit which accepts an SI prefix. There is no "name1" field because it
-- has to be constructed (mJ gives "millijoule"; MJ gives "megajoule").
-- {{convert|125|kJ}} → 125 kilojoules (30,000 cal)
["J"] = {
_name1 = "joule",
_symbol = "J",
utype = "energy",
scale = 1,
prefixes = 1,
default = "cal",
link = "Joule",
},
-- A unit where US and plural names are required.
-- {{convert|125|cm/s2}} → 125 centimetres per second squared (4.1 ft/s²)
["cm/s2"] = {
name1 = "centimetre per second squared",
name1_us = "centimeter per second squared",
name2 = "centimetres per second squared",
name2_us = "centimeters per second squared",
symbol = "cm/s<sup>2</sup>",
utype = "acceleration",
scale = 0.01,
default = "ft/s2",
link = "Gal (unit)",
},
-- A "per" unit is defined as the ratio of two other units.
-- {{convert|125|g/cm3}} → 125 grams per cubic centimetre (4.5 lb/cu in)
["g/cm3"] = {
per = { "g", "cm3" },
utype = "density",
default = "lb/cuin",
},
-- If the automatic "per" link is not wanted, a link can be specified.
-- {{convert|125|g/cm3|lk=on|disp=unit}} → [[gram]]s per [[cubic centimetre]]
-- {{convert|125|g/m3|lk=on|disp=unit}} → [[density|grams per cubic metre]]
["g/m3"] = {
per = { "g", "m3" },
utype = "density",
default = "lb/cuyd",
link = "density",
},
-- Characters "$" and "£" are recognized as currency symbols.
-- {{convert|125|$/acre}} → $125 per acre ($310/ha)
["$/acre"] = {
per = { "$", "acre" },
utype = "cost $ per unit area",
default = "$/ha",
},
-- An output unit can be defined as a combination of existing units.
-- {{convert|2|ha|ft2 m2}} → 2 hectares (220,000 sq ft; 20,000 m²)
-- Any number of output units can be specified.
-- NOTE: There may be no need to define a combination because a convert
-- can specify the output by joining unit codes with "+":
-- {{convert|1.2|acre|ft2+yd2+m2}} → 1.2 acres (52,000 sq ft; 5,800 sq yd; 4,900 m²)
["ft2 m2"] = {
combination = { "ft2", "m2" },
utype = "area",
},
-- An output unit can be defined using subunits (from least to most significant).
-- {{convert|90|in|ydftin}} → 90 inches (2 yd 1 ft 6 in)
["ydftin"] = {
combination = { "in", "ft", "yd" },
multiple = { 12, 3 },
utype = "length",
},
}
|
Field | Description |
---|---|
symbol |
Unit identifier used when abbr=on is in effect.
|
name1 |
Singular name of the unit used when abbr=off is in effect.
|
name2 |
Plural name of the unit; not required if it is the same as name1 plus "s".
|
name1_us |
Singular name when sp=us is in effect; not required if the same as name1 .
|
name2_us |
Plural name when sp=us is in effect; not required if the same as name1_us plus "s".
|
utype |
Unit type; must be exactly the same as the utype of any other unit used in a conversion.
|
scale |
Number of base units in the unit being defined. |
default |
Unit code of the default output used when no output unit is specified in a conversion. |
target |
Unit code of an existing unit (the unit being defined "redirects" to the existing unit). |
prefixes |
Use 1 if an SI prefix is accepted; 2 is used for m2 , and 3 is used for m3 .
|
link |
Article title used when lk=on is in effect; not required if it is the same as name1 .
|
Zgornja dokumentacija je vključena iz Modul:Convert/extra/dok. (uredi | zgodovina) Urejevalci lahko preizkušate ta modul v peskovniku (uredi | primerjava) in testnihprimerih (ustvari). Prosimo, da dodate kategorije v /dok podstran. Podstrani te predloge. |
-- Extra conversion data used by Module:Convert.
--
-- [[Module:Convert/data]] defines all units and is transcluded in all pages
-- where [[Module:Convert]] is used. Testing new units by editing that module
-- would invalidate the cache for all affected pages.
--
-- For quick changes and experiments with new units, this module can be edited.
-- Since this module is transcluded in only a small number of pages, changes
-- should cause little server overhead and should propagate quickly.
--
-- If a unit is defined in the data module, any definition here is ignored,
-- so defining the same unit in both modules is not an error.
-- A unit defined here can refer to units that are also defined here, and
-- can refer to units defined in the data module.
--
-- Periodically, those extra units that are wanted permanently can be removed
-- from here after being added to [[Module:Convert/data]].
local extra_units = {
["$/g"] = {
per = { "$", "g" },
utype = "cost $ per unit mass",
default = "$/lb",
},
["$/oz"] = {
per = { "$", "oz" },
utype = "cost $ per unit mass",
default = "$/g",
},
["gr water"] = {
name1 = "grains water",
name2 = "grains water",
symbol = "gr H<sub>2</sub>O",
utype = "volume",
scale = 0.00000006479891,
default = "cm3",
link = "Grain (unit)",
},
["lb(f)"] = {
name1 = "pound",
symbol = "lb",
utype = "force",
scale = 4.4482216152605,
default = "N",
link = "Pound-force",
},
["dpi"] = {
name1 = "DPI",
name2 = "DPI",
symbol = "DPI",
utype = "length",
invert = -1,
iscomplex= true,
scale = 1/0.0254,
default = "pitch",
link = "Dots per inch",
},
-- the convention is that resolution appears as simply micrometers dimensionally
-- see Digital Photogrammetry: A Practical Course by Wilfried Linder
["pitch"] = {
name1 = "µm",
name2 = "µm",
symbol = "µm",
utype = "length",
invert = 1,
scale = 0.000001,
default = "dpi",
link = "Dots_per_inch#Proposed_metrication",
},
["dpcm"] = {
name1 = "dot/cm",
name2 = "dot/cm",
symbol = "dot/cm",
utype = "length",
invert = -1,
iscomplex= true,
scale = 1/0.01,
default = "dpi",
link = "Dots_per_inch#Proposed_metrication",
},
["isp"] = {
name1 = "second",
name2 = "seconds";
symbol = "s",
utype = "speed",
invert = 1,
scale = 9.8066,
default = "km/s",
link = "specific impulse",
},
-- from F=ma, Ns/kg is equivalent to units of speed
-- which is fortunate because convert couldn't handle it otherwise
["Ns/kg"] = {
name1 = "N-s/kg",
name2 = "N-s/kg";
symbol = "N-s/kg",
utype = "speed",
invert = 1,
scale = 1,
default = "isp",
link = "specific impulse",
},
["kNs/kg"] = {
name1 = "kN-s/kg",
name2 = "kN-s/kg";
symbol = "kN-s/kg",
utype = "speed",
invert = 1,
scale = 1000,
default = "isp",
link = "specific impulse",
},
-- units of inverse speed, because invert is negative
["si tsfc"] = {
name1 = "g/(kN·s)",
name2 = "g/(kN·s)",
symbol = "g/(kN·s)",
utype = "speed",
invert = -1,
iscomplex= true,
scale = 1/101972/9.8066,
default = "tsfc",
link = "thrust specific fuel consumption",
},
-- units of inverse speed, because invert is negative
["tsfc"] = {
name1 = "lb/(lbf·h)",
name2 = "lb/(lbf·h)",
symbol = "lb/(lbf·h)",
utype = "speed",
invert = -1,
iscomplex= true,
scale = 1/9.8066/3600,
default = "si_tsfc",
link = "thrust specific fuel consumption",
},
["LB"] = {
-- Experiment: same as "lb" but with extra default precision.
name1 = "pound",
symbol = "lb",
utype = "mass",
scale = 0.45359237,
exception= "integer_more_precision",
default = "kg",
subdivs = { ["oz"] = { 16, default = "kg" } },
link = "Pound (mass)",
},
["LB stlb"] = {
combination= { "LB", "stlb" },
utype = "mass",
},
["hp/t"] = {
name1 = "horsepower per tonne",
name2 = "horsepower per tonne",
symbol = "hp/t",
utype = "power per unit mass",
scale = 0.74569987158227022,
default = "kW/t",
link = "Power-to-weight ratio",
},
["hp/tonne"] = {
target = "hp/t",
symbol = "hp/tonne",
default = "kW/tonne",
},
["kW/tonne"] = {
target = "kW/t",
symbol = "kW/tonne",
},
["km3/d"] = {
name1 = "cubic kilometre per day",
name1_us = "cubic kilometer per day",
name2 = "cubic kilometres per day",
name2_us = "cubic kilometers per day",
symbol = "km<sup>3</sup>/d",
utype = "flow",
scale = 11574.074074074075,
default = "cuft/d",
link = "Cubic metre per second",
},
["Sv"] = {
_name1 = "sievert",
_symbol = "Sv",
utype = "equivalent radiation dose",
scale = 1,
prefixes = 1,
default = "rem",
link = "Sievert",
},
["rem"] = {
_name1 = "rem",
_symbol = "rem",
utype = "equivalent radiation dose",
scale = 0.01,
prefixes = 1,
default = "Sv",
link = "Roentgen equivalent man",
},
["Gy"] = {
_name1 = "gray",
_symbol = "Gy",
utype = "absorbed radiation dose",
scale = 1,
prefixes = 1,
default = "rad",
link = "Gray (unit)",
},
["rad"] = {
_name1 = "rad",
_symbol = "rad",
utype = "absorbed radiation dose",
scale = 0.01,
prefixes = 1,
default = "Gy",
link = "Rad (unit)",
},
["A/m"] = {
name1 = "amp per metre",
name1_us = "amp per meter",
name2 = "amps per metre",
name2_us = "amps per meter",
symbol = "A/m",
utype = "magnetizing field",
scale = 1,
default = "Oe",
link = "Magnetic field#Units",
},
["kA/m"] = {
name1 = "kiloamp per metre",
name1_us = "kiloamp per meter",
name2 = "kiloamps per metre",
name2_us = "kiloamps per meter",
symbol = "kA/m",
utype = "magnetizing field",
scale = 1000,
default = "kOe",
link = "Magnetic field#Units",
},
["MA/m"] = {
name1 = "megaamp per metre",
name1_us = "megaamp per meter",
name2 = "megaamps per metre",
name2_us = "megaamps per meter",
symbol = "MA/m",
utype = "magnetizing field",
scale = 1000000,
default = "kOe",
link = "Magnetic field#Units",
},
["Oe"] = {
_name1 = "oersted",
_symbol = "Oe",
utype = "magnetizing field",
scale = 79.5774715,
prefixes = 1,
default = "kA/m",
link = "Oersted",
},
}
return { extra_units = extra_units }