Debian Codegraph @

gavo/resources/inputs/__system__/linetap.rd

raw
1 <resource schema="__system">
2 <!-- TODO: Updater für coverage schreiben -->
3 <meta name="creationDate">2022-02-10T13:26:00Z</meta>
4 <meta name="subject">spectral-line-identification</meta>
5 <meta name="description">A mixin and other support material for
6 LineTAP.</meta>
7
8 <STREAM id="linetap-columns">
9 <column name="title" type="text" required="True"
10 ucd="meta.id"
11 tablehead="Line name"
12 description="Human-readable line designation.">
13 <property name="std">1</property>
14 </column>
15 <column name="vacuum_wavelength" type="double precision" required="True"
16 ucd="em.wl" unit="Angstrom"
17 description="Vacuum wavelength of the transition">
18 <property name="std">1</property>
19 </column>
20 <column name="vacuum_wavelength_error" type="double precision"
21 ucd="stat.error;em.wl" unit="Angstrom"
22 description="Total error in vacuum_wavelength">
23 <property name="std">1</property>
24 </column>
25
26 <column name="method" type="text"
27 ucd="meta.code.class"
28 description="Method the wavelength was obtained with
29 (XSAMS controlled vocabulary)">
30 <values>
31 <option>observed</option>
32 <option>theory</option>
33 <option>ritz</option>
34 </values>
35 <property name="std">1</property>
36 </column>
37
38 <column name="element" type="text"
39 ucd="phys.atmol.element"
40 tablehead="Element"
41 description="Element name for atomic transitions,
42 NULL otherwise.">
43 <property name="std">1</property>
44 </column>
45 <column name="ion_charge" type="integer" required="True"
46 ucd="phys.electCharge"
47 description="Total charge (ionisation level) of the emitting
48 particle.">
49 <property name="std">1</property>
50 </column>
51 <column name="mass_number" type="integer"
52 ucd="phys.atmol.weight"
53 description="Number of nucleons in the atom or molecule">
54 <values nullLiteral="-1"/>
55 <property name="std">1</property>
56 </column>
57
58 <column name="upper_energy" type="double precision"
59 ucd="phys.energy;phys.atmol.initial" unit="J"
60 description="Energy of the upper state">
61 <property name="std">1</property>
62 </column>
63 <column name="lower_energy" type="double precision"
64 ucd="phys.energy;phys.atmol.final" unit="J"
65 description="Energy of the lower state">
66 <property name="std">1</property>
67 </column>
68
69 <column name="inchi" type="text" required="True"
70 ucd="meta.id;phys.atmol;meta.main"
71 description="International Chemical Identifier InChI.">
72 <property name="std">1</property>
73 </column>
74 <column name="inchikey" type="text" required="True"
75 ucd="meta.id;phys.atmol"
76 description="The InChi key (hash) generated from inchi.">
77 <property name="std">1</property>
78 </column>
79
80 <column name="einstein_a" type="double precision"
81 ucd="phys.atmol.transProb"
82 description="Einstein A coefficient of the radiative transition.">
83 <property name="std">1</property>
84 </column>
85
86 <!-- May 2022: We believe A_ik is good enough for our use cases. Do away
87 with the other strength measures if people do not complain very loudly.
88 <column name="oscillator_strength" type="double precision"
89 ucd="phys.atmol.oscStrength"
90 description="Oscillator strength of the radiative transition.">
91 <property name="std">1</property>
92 </column>
93 <column name="weighted_oscillator_strength" type="double precision"
94 ucd="phys.atmol.wOscStrength"
95 description="Weighted oscillator strength of the radiative
96 transition">
97 <property name="std">1</property>
98 </column>
99 <column name="line_strength" type="double precision"
100 ucd="spect.line.strength"
101 description="Total absorption by a spectra line">
102 <property name="std">1</property>
103 </column> -->
104
105 <column name="xsams_uri" type="text"
106 ucd="meta.ref"
107 description="A URI for a full XSAMS description of this line.">
108 <property name="std">1</property>
109 </column>
110 <column name="line_reference" type="text" required="True"
111 ucd="meta.ref"
112 description="Reference to the source of the line data; this could
113 be a bibcode, a DOI, or a plain URI.">
114 <property name="std">1</property>
115 </column>
116 </STREAM>
117
118 <mixinDef id="table-0">
119 <doc><![CDATA[
120 This mixin makes a table suitable for publication as a LineTAP
121 table.
122
123 It provides all standard columns, makes sure it is on disk and
124 available through TAP, adds the most common indexes, and gives it the
125 utype required by the standard.
126
127 It is recommended to fill this table with a rowmaker using the
128 `//linetap#populate-0`_ apply.
129 ]]></doc>
130
131 <events>
132 <adql>True</adql>
133 <onDisk>True</onDisk>
134 <meta name="utype">ivo://ivoa.net/std/linetap#lines-1.0</meta>
135
136 <FEED source="linetap-columns"/>
137 </events>
138 </mixinDef>
139
140 <procDef type="apply" id="populate-0">
141 <doc><![CDATA[
142 Fills the columns of a LineTAP table, typically created using
143 `the //linetap#table-0 mixin`_. The values are left in
144 vars, so you need to copy them into the finished record,
145 probably through ``idmaps="*"``.
146 ]]></doc>
147 <setup imports="gavo.protocols.linetap">
148 <LOOP>
149 # turn our LineTAP columns into apply params
150 <codeItems>
151 mixin = context.getById("table-0")
152 dicts = [{}]
153 for type, name, content, _ in mixin.events.events_:
154 if type=="value":
155 dicts[-1][name] = content
156
157 elif type=="start":
158 dicts.append({})
159
160 elif type=="end":
161 res = dicts.pop()
162 if name=="column":
163 res["default"] = (
164 "" if res.get("required", False) else "None")
165 if res.get("unit"):
166 res["description"] += " (in {})".format(res["unit"])
167
168 yield res
169 </codeItems>
170 <events>
171 <par key="\name" description="\description"
172 late="True">\default</par>
173 </events>
174 </LOOP>
175 <!-- The InChIKey we generally compute ourselves, so give it
176 a different default and comment -->
177 <par key="inchikey"
178 description="The hashed InChI; the proc will generally compute
179 the hash from the InChI itself, so you will usually want to
180 leave this empty." late="True">base.NotGiven</par>
181 <code>
182 INCHILIB = linetap.getILib()
183 </code>
184 </setup>
185 <code>
186 if inchikey is base.NotGiven:
187 inchikey = INCHILIB.getInChIKey(inchi)
188 vars.update(locals())
189 </code>
190 </procDef>
191
192 <procDef type="apply" id="InChIForAtom">
193 <doc><![CDATA[
194 Puts the InChI of a simple (possibly ionised) atom into
195 the inchi var. The intended use is like this::
196
197 <apply procDef="InChIForAtom">
198 <bind name="element">@element</bind>
199 <bind name="charge">@ion_charge</bind>
200 </apply>
201
202 <apply procDef="//linetap#populate-0">
203 ...
204 <bind name="inchi">@inchi</bind>
205 </apply>
206
207 The apply caches the computed InChI; there is no need to do extra
208 caching.
209 ]]></doc>
210 <setup imports="gavo.protocols.linetap, functools">
211 <par key="element" description="The standard element symbol (H, He,...)
212 to generate an InChI for" late="True"/>
213 <par key="charge" description="The charge of the atom in elementary
214 charges" late="True">0</par>
215 <code>
216 INCHILIB = linetap.getILib()
217
218 def getInChI(element, charge):
219 iin = INCHILIB.getInput([
220 INCHILIB.getAtom(element, charge=charge)])
221
222 return INCHILIB.getInChI(iin)
223
224 getInChI = functools.cache(getInChI)
225 </code>
226 </setup>
227 <code>
228 @inchi = getInChI(element, charge)
229 </code>
230 </procDef>
231 </resource>