<resource schema="__system">
	<meta name="creationDate">2022-02-10T13:26:00Z</meta>
	<meta name="subject">spectral-line-identification</meta>
	<meta name="description">A mixin and other support material for
		LineTAP.</meta>

	<STREAM id="linetap-columns">
		<column name="title" type="text" required="True"
			ucd="meta.id"
			tablehead="Line name"
			description="Human-readable line designation."/>
		<column name="vacuum_wavelength" type="double precision" required="True"
			ucd="em.wl" unit="Angstrom" 
			description="Vacuum wavelength of the transition"/>
		<column name="vacuum_wavelength_error" type="double precision" 
			ucd="stat.error;em.wl" unit="Angstrom" 
			description="Total error in vacuum_wavelength; this
				should be something like the FWHM of a Gaussian fit to the
				true distribution."/>

		<column name="method" type="text" 
				ucd="meta.code.class"
				description="Method the wavelength was obtained with 
					(observed/theory/ritz)">
			<values>
				<option>observed</option>
				<option>theory</option>
				<option>ritz</option>
			</values>
		</column>

		<column name="ion_charge" type="integer" required="True"
			ucd="phys.electCharge"
			description="Total charge (ionisation level) of the emitting
				particle."/>
		<column name="mass_number" type="integer"
			ucd="phys.atmol.weight"
			description="Number of nucleons in the atom or molecule">
			<values nullLiteral="-1"/>
		</column>

		<column name="upper_state_configuration" type="text" 
			ucd="phys.atmol.configuration;phys.atmol.initial"
			description="Electronic configuration in the upper state"/>
		<column name="lower_state_configuration" type="text" 
			ucd="phys.atmol.configuration;phys.atmol.final"
			description="Electronic configuration in the upper state"/>
		<column name="upper_energy" type="double precision" 
			ucd="phys.energy;phys.atmol.initial" unit="J" 
			description="Energy of the upper state"/>
		<column name="lower_energy" type="double precision" 
			ucd="phys.energy;phys.atmol.final" unit="J" 
			description="Energy of the lower state"/>

		<column name="inchi" type="text" required="True"
			ucd="meta.id;phys.atmol;meta.main"
			description="International Chemical Identifier InChI.  The main layer is
				mandatory, the charge, stereochemical, and isotopic layers optional."/>
		<column name="inchikey" type="text" required="True"
			ucd="meta.id;phys.atmol"
			description="The InChi key (hash) generated from inchi."/>
		
		<column name="einstein_a" type="double precision" 
			ucd="phys.atmol.wOscStrength"
			description="Einstein A coefficient of the radiative transition."/>
		<column name="oscillator_strength" type="double precision" 
			ucd="phys.atmol.oscStrength"
			description="Oscillator strength of the radiative transition."/>
		<column name="weighted_oscillator_strength" type="double precision" 
			ucd="phys.atmol.wOscStrength"
			description="Weighted oscillator strength of the radiative
				transition"/>
		<column name="line_strength" type="double precision" 
			ucd="spect.line.strength"
			description="Total absorption by a spectra line"/>
		<column name="line_reference" type="text" 
			ucd="meta.ref"
			description="Reference to the source of the line data; this could
				be a bibcode, a DOI, or a plain URI."/>
	</STREAM>

	<mixinDef id="table-0">
		<doc><![CDATA[
			This mixin makes a table suitable for publication as a LineTAP
			table.

			It provides all standard columns, makes sure it is on disk and
			available through TAP, adds the most common indexes, and gives it the
			utype required by the standard.

			It is recommended to fill this table with a rowmaker using the
			`//linetap#populate-0`_ apply.
		]]></doc>

		<events>
			<adql>True</adql>
			<onDisk>True</onDisk>
			<meta name="utype">ivo://ivoa.net/std/linetap#table-1.0</meta>

			<FEED source="linetap-columns"/>
		</events>
	</mixinDef>

	<procDef type="apply" id="populate-0">
		<doc><![CDATA[
			Fills the columns of a LineTAP table, typically created using
			`the //linetap#table-0 mixin`_.  The values are left in
			vars, so you need to copy them into the finished record,
			probably through ``idmaps="*"``.
		]]></doc>
		<setup>
			<LOOP>
				# turn our LineTAP columns into apply params
				<codeItems>
					mixin = context.getById("table-0")
					colDict = {}
					for type, name, content, _ in mixin.events.events_:
						if type=="value":
							colDict[name] = content
						elif type=="end":
							if name=="column":
								colDict["default"] = (
									"" if colDict.get("required", False) else "None")
								yield colDict
								colDict = {}
				</codeItems>
				<events>
					<par key="\name" description="\description" 
						late="True">\default</par>
				</events>
			</LOOP>
		</setup>
		<code>
			vars.update(locals())
		</code>
	</procDef>
</resource>
