<resource schema="smakced">
	<meta name="creationDate">2014-07-15T10:21:00Z</meta>
	<meta name="schema-rank">100</meta>
	<meta name="title">A Near-infrared Census of the Multicomponent Stellar
		Structure of Early-type Dwarf Galaxies in the Virgo Cluster</meta>
	<meta name="description" format="rst">
		The Stellar content, MAss and Kinematics of Cluster Early-type Dwarf
		galaxies (SMAKCED_) project is a survey of 121 Virgo cluster early type
		galaxies.  This service publishes deep near-infrared (H band) images
		obtained by SMAKCED together with `resulting decompositions`_ and other
		properties of the galaxies in the sample.

		.. _SMAKCED: http://smakced.net
		.. _resulting decompositions: http://smakced.net/data.html
	</meta>
	<meta name="source">2014ApJ...786..105J</meta>
	<meta name="coverage.waveband">Infrared</meta>

	<meta name="creator">Janz, J.; Laurikainen, E.; Lisker, T.; Salo, H.;
		Peletier, R. F.; Niemi, S.-M.; Toloba, E.; Hensler, G.; Falcón-Barroso, J.;
		Boselli, A.; den Brok, M.; Hansson, K. S. A.; Meyer, H. T.; Ryś, A.;
		Paudel, S.
	</meta>

	<meta>
		subject: dwarf-galaxies
		subject: early-type-galaxies
		subject: virgo-cluster
		subject: surface-photometry
		subject: infrared-photometry
	</meta>

	<meta name="_longdoc" format="rst">
		The images are calibrated such that

		::
			
			mag_H = -2.5 log(counts)

		(in the 2MASS photometric system) without the need for an
		additional zeropoint.  Extinction correction according to
		`1998ApJ...500..525S`_ is already applied to these values.

		.. _1998ApJ...500..525S: http://adsabs.harvard.edu/abs/1998ApJ...500..525S
	</meta>

	<STREAM id="t3columns">
		<doc>columns pulled input main from the paper's table 3.</doc>

		<column name="raj2000" type="double precision"
			unit="deg" ucd="pos.eq.ra;meta.main"
			tablehead="RA"
			description="ICRS RA of galaxy center from asymmetry centering
				(unless specified otherwise in remarks)."
			verbLevel="9" displayHint="sf=4"/>
		<column name="dej2000" type="double precision"
			unit="deg" ucd="pos.eq.dec;meta.main"
			tablehead="Dec"
			description="ICRS Declination of galaxy center from asymmetry centering
				(unless specified otherwise in remarks)."
			verbLevel="9" displayHint="sf=4"/>
		<column name="exptime"
			unit="s" ucd="time.duration;obs.exposure"
			tablehead="Exp. time"
			description="Total integration time for the object (sum of
				exposure times of all images stacked; note that different telescopes
				were in use)."
			verbLevel="15"/>
		<column name="seeing"
			unit="arcsec" ucd="instr.obsty.seeing"
			tablehead="Seeing"
			description="Estimate for the seeing at observation time."
			verbLevel="15"/>
		<column name="snr"
			ucd="stat.snr"
			tablehead="S/N"
			description="Signal to noise ratio for a pixel at 2 r_e."
			verbLevel="15"/>
		<column name="hmag"
			ucd="phot.mag;em.ir.H"
			tablehead="m_H"
			description="Total H-band magnitude of the galaxy"
			verbLevel="15"/>

		<column name="r_e"
			unit="arcsec" ucd="phys.angSize"
			tablehead="r_e"
			description="Effective radius of the galaxy (semi-major axis of
				half-light aperture in H)."
			verbLevel="15"/>
		<column name="b_a"
			ucd="phys.angSize;arith.ratio"
			tablehead="b/a"
			description="Axis raio at 2 r_e"
			verbLevel="15"/>
		<column name="concentration"
			ucd="phys.size;arith.ratio"
			tablehead="C"
			description="Concentration index 5 log_80/r_20 as in
				2000AJ....119.2645B"
			verbLevel="15"/>
		<column name="rho10"
			unit="log(deg**-2)" ucd="src.density"
			tablehead="log ρ_10"
			description="Local projected number density of cluster galaxies.
				(see Appendix D in the source)"
			verbLevel="15"/>

		<column name="remarks" type="text"
			ucd="meta.note"
			tablehead="Remarks"
			description="Morphological features from 2006AJ....132.2432L and other
				remarks"
			verbLevel="15"/>
		<column name="moreinfo" type="text"
			ucd="meta.ref"
			tablehead="More"
			description="Bibcodes of papers containing more information."
			verbLevel="20" displayHint="type=bibcode"/>
	</STREAM>

	<STREAM id="t5columns">
		<doc>columns pulled input main from the paper's table 5.</doc>
		<column name="structgroup" type="text"
			ucd='meta.code.class'
			tablehead="Group"
			description="Structural Group (see 2012ApJ...745L..24J)
				resulting from the decomposition."
			verbLevel="15"/>

		<LOOP>
			<csvItems>
				shortName, modelDesc
				simp,      simple model
				inner,     inner component
				outer,     global/outer component
			</csvItems>
			<events>
				<column name="\shortName\+_m"
					unit="mag" ucd="phot.mag;em.ir.H"
					tablehead="m(\shortName)"
					description="Integrated H-band  brightness, \modelDesc"
					verbLevel="19"/>
				<column name="\shortName\+_rc"
					unit="arcsec" ucd="phys.angSize;src"
					tablehead="r_c(\shortName)"
					description="Half-light radius, \modelDesc"
					verbLevel="19"/>
				<column name="\shortName\+_n"
					ucd="stat.fit.param"
					tablehead="n(\shortName)"
					description="Sérsic index, \modelDesc"
					verbLevel="19"/>
				<column name="\shortName\+_b_a"
					ucd="phys.angSize;arith.ratio"
					tablehead="b/a(\shortName)"
					description="Axis ratio, \modelDesc"
					verbLevel="19"/>
			</events>
		</LOOP>

		<LOOP>
			<csvItems>
				colname, desc
				simpdec,  single decomposition
				finaldec,   final decomposition
			</csvItems>
			<events>
				<column name="\colname\+_rff"
					ucd="stat.fit.goodness"
					tablehead="RFF(\colname)"
					description="Residual flux fraction (2006ApJ...644...30B) for
						the \desc"
					verbLevel="22"/>
				<column name="\colname\+_evi"
					ucd="stat.fit.goodness"
					tablehead="EVI(\colname)"
					description="Excess variance index (2011MNRAS.411.2439H)
						for \desc"
					verbLevel="22"/>
			</events>
		</LOOP>
		<column name="compmorph" type="text"
			ucd="meta.note;src.morph"
			tablehead="Add. info"
			description="Additional information on decomposition."
			verbLevel="17"/>
	</STREAM>

	<table id="main" onDisk="True" mixin="//siap#pgs" adql="True">
		<meta name="description">SMAKCED infrared images and derived properties
		of early-type dwarf galaxies in the Virgo cluster.</meta>

		<column name="OBJECT" type="text" required="True"
			ucd="meta.id;meta.main"
			tablehead="Galaxy name" verbLevel="15"
			description="Common name of the observed galaxy."/>
		<FEED source="t3columns"/>
		<FEED source="t5columns"/>
		<column name="dateObs"  ucd="time;obs.exposure"
			type="double precision" unit="d" tablehead="Approx. date"
			verbLevel="1" description="Approximate observation date
				(essentially, month and year should be about right).  NULL
				for archival material"
			displayHint="type=humanDate"
			xtype="mjd"/>
	</table>

	<data id="import_main">
		<property key="previewDir">previews</property>
		<sources pattern="data/*.fits"/>
		<fitsProdGrammar qnd="True">
			<rowfilter procDef="//products#define">
				<bind key="table">"\schema.main"</bind>
				<bind key="preview">\standardPreviewPath</bind>
				<bind key="preview_mime">"image/jpeg"</bind>
			</rowfilter>
		</fitsProdGrammar>

		<make table="main" >
			<rowmaker idmaps="OBJECT, raj2000, dej2000, exptime,
					seeing, snr, hmag, r_e, b_a, concentration, rho10, remarks,
					moreinfo, structgroup, simp_m, simp_rc, simp_n, simp_b_a,
					inner_m, inner_rc, inner_n, inner_b_a,
					outer_m, outer_rc, outer_n, outer_b_a,
					simpdec_rff, simpdec_evi,
					finaldec_rff, finaldec_evi, compmorph"
					id="rmk_main">
				<var key="OBJECT">str(@prodtblAccref.split("/")[
					-1].split("_")[0])</var>
				<var key="title">"SMAKCED H band %s"%(@OBJECT)</var>

				<apply name="wcsStopgap">
					<!-- for some reason they couldn't calibrate VCC1183 and one
					other and instead put in totally whacky mess.   To at least
					have these things in in some way, I'm monkeypatching
					the header.

					This should *definitely* be fixed in the data.  Remove this apply
					then. -->
					<code>
						if abs(@CRPIX1)>10000:
							@CRPIX1 = @CRPIX2 = 0
							@CD1_1 = -8e-5
							@CD2_2 = 8e-5
							@CD1_2 = @CD2_1 = 0
					</code>
				</apply>

				<!-- let computePGS run before any info is pulled in from
				other tables - pyfits currently cannot deal with unicode
				objects, and so you'd get "Illegal value" errors. -->
				<apply procDef="//siap#computePGS"/>

				<LOOP listItems="3 5">
					<events>
						<apply name="pullFromTable\item">
							<setup>
								<code>
									from gavo import api
									table = api.makeData(rd.getById("import_table\item")
										).getPrimaryTable()
								</code>
							</setup>
							<code>
								try:
									vars.update(table.getRow(@OBJECT))
								except KeyError:
									pass
							</code>
						</apply>
					</events>
				</LOOP>

				<apply procDef="//procs#dictMap" name="mapInstrumentNames">
					<bind key="key">"instrument"</bind>
					<bind key="mapping">{
						'NTT': "SOFI at ESO New Technology Telescope",
						'TNG': "NICS at Telescopio Nazionale Galileo",
						'NOT': "NOTCam at Nordic Optical Telescope",
						'Archival': "Archival data from ESO NTT and/or Nordic Optical",
					}</bind>
				</apply>

				<apply procDef="//procs#dictMap" name="mapObsDate">
					<bind key="key">"campaign"</bind>
					<bind key="mapping">{
						'2010/Jan': datetime.datetime(2010, 1, 15),
						'2010/Mar': datetime.datetime(2010, 3, 15),
						'2010/Apr': datetime.datetime(2010, 4, 15),
						'2011/Mar': datetime.datetime(2011, 3, 15),
						'2011/Apr': datetime.datetime(2011, 4, 15),
						'2012/Mar': datetime.datetime(2012, 3, 15),
						'Archive': None,}
					</bind>
				</apply>

				<apply procDef="//siap#setMeta">
					<bind name="bandpassId">"2MASS H"</bind>
					<bind name="bandpassUnit">"m"</bind>
					<bind name="instrument">@instrument</bind>
					<bind name="dateObs">@campaign</bind>
					<bind name="title">@title</bind>
					<bind name="pixflags">"Z"</bind>
				</apply>
				<apply procDef="//siap#getBandFromFilter"/>
			</rowmaker>
		</make>
	</data>

	<!-- ================================ Helper tables ============= -->

	<table id="table3" primary="object_key">
		<meta name="description">Temporary table containing information from
		the paper's table 3.  On disk, the information is part of smakced.main.
		</meta>

		<column name="object_key" type="text"/> <!-- match against object -->
		<column name="instrument" type="text"/> <!-- to siap metadata -->
		<column name="campaign" type="text"/> <!-- turned into dateObs -->
		
		<FEED source="t3columns"/>
	</table>

	<data id="import_table3" auto="False">
		<sources>textinputs/table3.tex</sources>
		<reGrammar topIgnoredLines="1" fieldSep="\s*&amp;\s*" commentPat="\\\\">
			<names>object_key, raseg, deseg, instrument, campaign, exptime_minutes,
				seeing, snr, hmag, r_e, b_a, concentration, rho10, remarks_goo
			</names>
		</reGrammar>

		<make table="table3">
			<rowmaker idmaps="object_key, seeing, r_e, b_a, concentration, rho10,
					hmag, instrument, campaign">
				<map key="raj2000">hmsToDeg(
					re.sub("[^0-9.:+-]+", "", @raseg), sepChar=":")</map>
				<map key="dej2000">dmsToDeg(
					re.sub("[^0-9.:+-]+", "", @deseg), sepChar=":")</map>
				<map key="exptime">float(@exptime_minutes)*60</map>
				<map key="snr" nullExcs="ValueError"/>

				<apply name="parseRemarks">
					<setup>
						<code>
							refcodes = {
								'G01': "2001A&amp;A...372...29G",
								'G00': "2001A&amp;A...372...29G",
								'F06': "2006APJS..164..334F",
								'M11': "2011MNRAS.414.2055M"}
						</code>
					</setup>
					<code>
						refs = []
						for key, bib in refcodes.iteritems():
							if key in @remarks_goo:
								refs.append(bib)
						result["moreinfo"] = ", ".join(refs)
						
						features = []
						if r"{\\it sp}" in @remarks_goo:
							features.append("spiral?")
						elif "sp" in @remarks_goo:
							features.append("spiral")
						if r"{\\it b}" in @remarks_goo:
							features.append("bar?")
						elif "b" in @remarks_goo:
							features.append("bar")

						if r"\\it" in @raseg:
							features.append("Position from NED")
						
						result["remarks"] = ", ".join(features)
					</code>
				</apply>
			</rowmaker>
		</make>
	</data>

	<table id="table5" primary="object_key">
		<meta name="description">Temporary table containing information from
			the paper's table 5 (decomposition parameters).  On disk, the
			information is part of smakced.main</meta>
		<column name="object_key" type="text"/> <!-- match against object -->
		<FEED source="t5columns"/>
	</table>

	<data id="import_table5" auto="False">
		<sources>textinputs/table5.tex</sources>
		<reGrammar topIgnoredLines="3" fieldSep="\s*&amp;\s*" commentPat="\\\\"
			lax="True">
			<names>object_key, structgroup,
			simp_m, simp_rc, simp_n, simp_b_a,
			inner_m, inner_rc, inner_n, inner_b_a,
			outer_m, outer_rc, outer_n, outer_b_a,
			simpdec_rff, simpdec_evi,
			finaldec_rff, finaldec_evi,
			nucleus, addinfo
			</names>
		</reGrammar>
		<make table="table5">
			<rowmaker idmaps="object_key, compmorph, structgroup">
				<apply procDef="//procs#dictMap">
					<bind name="key">"structgroup"</bind>
					<bind name="mapping">{
						"L": "Lens",
						"1": "1-component",
						"2": "2-component",
						"B": "Bar",
						r"{\\it B}": "Bar?",
						r"{\\it L}": "Lens?",
						r"{\\it 1}": "1-component",
						r"{\\it 2}": "2-component",
					}</bind>
				</apply>

				<apply name="collectMorph">
					<code>
						items = []
						if @nucleus=='N':
							items.append("nucleus component used in decomposition")
						if "addinfo" in vars and @addinfo=='sp':
							items.append("hints of spiral arms in residual")
						@compmorph = "; ".join(items)
					</code>
				</apply>

				<LOOP listItems="simp_m simp_rc simp_n simp_b_a
						inner_m inner_rc inner_n inner_b_a
						outer_m outer_rc outer_n outer_b_a
						simpdec_rff simpdec_evi
						finaldec_rff finaldec_evi">
					<events>
						<map key="\item" nullExcs="ValueError"/>
					</events>
				</LOOP>
			</rowmaker>
		</make>
	</data>

	<coverage>
		<updater sourceTable="main"/>
			<spectral>1.07375e-19 1.37948e-19</spectral>
			<temporal>55211 56001</temporal>
			<spatial>4/1733,1746 5/6929,6931,6937,6941-6943,6965,6976,6978-6979,7008-7009,7011 6/26316,26318-26319,26362-26363,26365-26367,26538-26539,26542,27713,27715,27721,27723,27745,27753,27756,27758,27760-27761,27763,27857-27859,27864-27865,27868,27908,27910-27911,27930,27952,27954,27960,28041,28043,28056</spatial>
	</coverage>

	<!-- ================================ Services and such ========= -->

	<service id="im" allowed="siap.xml,form">
		<meta name="title">SMAKCED H-band images of Early-Type Virgo Dwarf
			Galaxies</meta>
		<meta name="shortName">smakced H images</meta>
		<meta name="sia.type">Pointed</meta>
		<meta name="relatedTo" ivoId="ivo://org.gavo.dc/smakced/q/cat"
			>SMAKCED Census of Structure in Early-type Dwarf Galaxies</meta>
		<meta name="testQuery">
			<meta>
				pos.ra: 187.035594243073
				pos.dec: 12.0941882809471
				size.ra: 0.01
				size.dec: 0.01
			</meta>
		</meta>

		<publish render="siap.xml" sets="ivo_managed"/>
		<publish render="form" sets="ivo_managed,local"/>

		<dbCore queriedTable="main">
			<condDesc original="//siap#protoInput"/>
			<condDesc original="//siap#humanInput"/>
			<condDesc buildFrom="dateObs"/>
			<condDesc id="objsel">
				<inputKey name="object" type="text"
						tablehead="Target Object"
						description="VCC identifier (like 'VCC0009')"
						ucd="meta.id" verbLevel="5" required="True"
						showItems="7">
						<values fromdb="object FROM \schema.main order by object"/>
				</inputKey>
			</condDesc>
		</dbCore>
	</service>

	<service id="cat" allowed="scs.xml,form">
		<meta name="title">SMAKCED Census of Structure in Early-type Dwarf
			Galaxies</meta>
		<meta name="shortName">smakced census</meta>
		<meta name="testQuery">
			<meta>
				ra: 187.035594243073
				dec: 12.0941882809471
				sr: 0.01
			</meta>
		</meta>
		<meta name="relatedTo" ivoId="ivo://org.gavo.dc/smakced/q/im"
			>SMAKCED H-band images of Early-Type Virgo Dwarf Galaxies</meta>

		<publish render="scs.xml" sets="ivo_managed"/>
		<publish render="form" sets="ivo_managed,local"/>

		<property name="votableRespectsOutputTable">True</property>

		<scsCore queriedTable="main">
		  <FEED source="//scs#coreDescs"/>
			<condDesc original="objsel"/>
			<condDesc buildFrom="r_e"/>
			<condDesc buildFrom="hmag"/>
		</scsCore>

		<outputTable>
			<LOOP listItems="OBJECT accref">
				<events>
					<outputField original="\item"/>
				</events>
			</LOOP>
			<outputField name="decomp" type="text"
				select=
					"'http://www.oulu.fi/astronomy/SMAKCED/2013/' || object || '.html'"
				ucd="meta.ref.url"
				tablehead="Decomp"
				description="Link to decomposition as produced by the authors."
				verbLevel="10"
				displayHint="type=url"/>
			<LOOP listItems="_r raj2000 dej2000
				structgroup compmorph hmag r_e b_a instId
				exptime concentration rho10
				simp_m simp_rc simp_n simp_b_a
				inner_m inner_rc inner_n inner_b_a
				outer_m outer_rc outer_n outer_b_a
				dateObs remarks moreinfo">
				<events>
					<outputField original="\item"/>
				</events>
			</LOOP>
		</outputTable>
	</service>
</resource>
