From 1017841f02e6582fc8f80954fb00a3c701cea906 Mon Sep 17 00:00:00 2001 From: mcdittmar Date: Tue, 2 Mar 2021 13:41:28 -0500 Subject: [PATCH 1/2] Add MCD implementation of Native Frames case --- .../mcd-implementation/README.md | 124 +++++++++ .../mcd-implementation/csc2_annotated.vot | 237 ++++++++++++++++++ 2 files changed, 361 insertions(+) create mode 100644 usecases/native_frames/mcd-implementation/README.md create mode 100644 usecases/native_frames/mcd-implementation/csc2_annotated.vot diff --git a/usecases/native_frames/mcd-implementation/README.md b/usecases/native_frames/mcd-implementation/README.md new file mode 100644 index 0000000..77c5a60 --- /dev/null +++ b/usecases/native_frames/mcd-implementation/README.md @@ -0,0 +1,124 @@ +# Implementation of 'Native-Frame' case + +# Overview + This case involves data extracted from the Chandra Source Catalog, Release 2.0 + containing Source ID and Position in 2 reference frames (ICRS, GALACTIC). + + The primary goals of the case appear to be + * Illustrate that the model allows for >1 instance of any given Property + + Positions in multiple reference frames + + Flux in multiple bands + + The data has been annotated using IVOA VO-DML Mapping syntax + * one Position using the Measurment model Position with Point coordinate, + which rama automatically converts to an astroPy SkyCoord. + * one Position using the Mango model LonLatSkyPosition with LonLatPoint coordinate. + + Annotation was produced using the 'Jovial' modeling toolset (Java). Jovial + was written by Omar Laurino, and updated by me to the current data model content. + It provides utilities to help define and create instances of (annotations) + IVOA VO-DML compliant data models. + + Uses the 'rama' python package to parse annotated data file and instantiate + instances of VO Data Model Classes. The package also applies Adapters which + translate certain VO Data Model Classes to corresponding AstroPY types. + eg: meas:Point -> astropy:SkyCoord + eg: meas:Time -> astropy:Time + This package was developed by Omar Laurino, and updated by me to the current + data model content. + +## Resources Used +* Mapping Syntax + + Working Draft document: + https://volute.g-vo.org/svn/trunk/projects/dm/vo-dml-mapping/doc/VO-DML_mapping_WD.pdf + +* Jovial Library + + version used in this project: + https://github.com/mcdittmar/jovial + + master repository: + https://github.com/olaurino/jovial + +* Rama module + + version used in this project: + https://github.com/mcdittmar/rama + + master repository: + https://github.com/olaurino/rama + +## Details +* Load Annotated VOTable + ``` + doc = Reader( Votable(infile) ) + ``` + +* **Goal: Find/Identify Positions (the long way)** + Note: LonLatSkyPosition|Point should be integrated with Position|Point + Note: rama auto-converts coords:Point to astropy:SkyCoord while mango:LonLatPoint remains in model representation + ``` + catalog = doc.find_instances(Source)[0] + positions = [] + for param in ( catalog.parameter_dock ): + if type(param.measure) in [ Position, LonLatSkyPosition ]: + if isinstance( param.measure.coord, SkyCoord ): + frame = param.measure.coord.frame.name + else: + frame = param.measure.coord.coord_sys.frame.space_ref_frame + sys.stdout.write("o Found Position in '%s' frame\n"%(frame)) + sys.stdout.write(" + coord type = %s\n"%str(type(param.measure.coord) )) + positions.append(param.measure) + ``` + o Found Position in 'icrs' frame + + coord type = + o Found Position in 'GALACTIC' frame + + coord type = + + +* **Goal: Create AstroPy SkyCoord from LonLatPosition** + Note: - the following can form an adapter on LonLatPoint to enable auto-convertion + ``` + coords1 = positions[0].coord + coords2 = SkyCoord( positions[1].coord.longitude, + positions[1].coord.latitude, + frame=positions[1].coord.coord_sys.frame.space_ref_frame.lower(), + equinox=positions[1].coord.coord_sys.frame.equinox, + unit=positions[1].coord.longitude.unit ) + sys.stdout.write("o coords1: type=%s, frame=%s\n"%(str(type(coords1)), coords1.frame.name )) + sys.stdout.write("o coords2: type=%s, frame=%s\n"%(str(type(coords2)), coords2.frame.name )) + ``` + o coords1: type=, frame=icrs + o coords2: type=, frame=galactic + +* **Goal: Convert both to common Frame - client's preferred frame** + ``` + coords1_user = coords1.transform_to(FK5(equinox="J2015.5")) + coords2_user = coords2.transform_to(FK5(equinox="J2015.5")) + sys.stdout.write("o coords1: type=%s, frame=%s\n"%(str(type(coords1_user)), coords1_user.frame.name )) + sys.stdout.write("o coords2: type=%s, frame=%s\n"%(str(type(coords2_user)), coords2_user.frame.name )) + ``` + o coords1: type=, frame=fk5 + o coords2: type=, frame=fk5 + +* **Goal: Plot the data** + Note: Since the original data are positions of the same source in different frames, these should overlap. + ``` + plt.figure( figsize=(6.5,6.5) ) + plt.suptitle("Plots of Source Data") + plt.subplots_adjust(top=0.90,bottom=0.1) + + ax1 = plt.subplot(211, projection="aitoff") + ax1.grid(True) + ra_rad = coords1_user.ra.wrap_at(180 * u.deg).radian + dec_rad = coords1_user.dec.radian + plt.plot(ra_rad, dec_rad, 'o', markersize=3, color="blue") + + ax2 = plt.subplot(212) + ax2.set_title("Overlay coordinates converted to common frame") + ax2.grid(True) + ax2.set_xlabel("RA [%s]"%coords1_user.ra.unit) + ax2.set_ylabel("DEC [%s]"%coords1_user.dec.unit) + + plt.plot( coords1_user.ra, coords1_user.dec,'o', markersize=3, color='blue') + plt.plot( coords2_user.ra, coords2_user.dec,'x', markersize=3, color='red') + + plt.show() + + ``` diff --git a/usecases/native_frames/mcd-implementation/csc2_annotated.vot b/usecases/native_frames/mcd-implementation/csc2_annotated.vot new file mode 100644 index 0000000..6a7570a --- /dev/null +++ b/usecases/native_frames/mcd-implementation/csc2_annotated.vot @@ -0,0 +1,237 @@ + + + VizieR Astronomical Server vizier.u-strasbg.fr + Date: 2021-01-21T13:05:40 [V1.99+ (14-Oct-2013)] + Explanations and Statistics of UCDs: See LINK below + In case of problem, please report to: cds-question@unistra.fr + In this version, NULL integer columns are written as an empty string + <TD></TD>, explicitely possible from VOTable-1.3 + + + + + + +-oc.form=dec +-out.max=10 +-nav=cat:IX/57&tab:{IX/57/csc2master}&key:source=IX/57&HTTPPRM:& +-c.eq=J2000 +-c.r= 2 +-c.u=arcmin +-c.geom=r +-source=IX/57/csc2master +-order=I +-out.orig=standard +-out=2CXO +-out=RAICRS +-out=DEICRS +-out=GLON +-out=GLAT + + + + + mango + file:/Users/sao/Documents/IVOA/GitHub/ivoa-dm-examples/tmp/Mango-v1.0.vo-dml.xml + + + meas + https://www.ivoa.net/xml/Meas/20200908/Meas-v1.0.vo-dml.xml + + + coords + https://www.ivoa.net/xml/STC/20200908/Coords-v1.0.vo-dml.xml + + + ivoa + https://www.ivoa.net/xml/VODML/IVOA-v1.vo-dml.xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + _coosys1 + + + + + + + + + + + + + + + + + + + + + + _coosys2 + + + + + + + + + + + + + + + The Chandra Source Catalog (CSC), Release 2.0 (Evans+, 2019) + + + Chandra Source Catalog, V2.0; master sources + + + + + + + Source name (Jhhmmss.s+ddmmssX) (name) + + + Source position, ICRS right ascension (ra) + + + Source position, ICRS declination (dec) + + + [-90/90] Source position, Galactic latitude (equinox J2000, epoch J2000) (gal_b) + + + [0/360] Source position, Galactic longitude (gal_l) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
J165541.6-424937253.9235440-42.82715813.34360e-013.42863e+02
J165643.7-424532254.1822020-42.75898672.29009e-013.43035e+02
J165650.6-423812254.2110170-42.63669002.88859e-013.43143e+02
J165655.8-423816254.2327631-42.63796422.75568e-013.43152e+02
J165649.7-423849254.2074791-42.64704462.84426e-013.43134e+02
J165659.9-423630254.2496619-42.60836182.84331e-013.43183e+02
J165658.8-423732254.2452153-42.62575542.76031e-013.43168e+02
J165703.7-425442254.2655991-42.91167138.59080e-023.42954e+02
J165719.8-425620254.3329099-42.93907713.02880e-023.42963e+02
J170103.4-404053255.2642189-40.68141908.82591e-013.45166e+02
+ matching records + + + + + truncated result (maxtup=10) + +
+
From 8a8a686e29763e528db45ea38ef16249672b5be8 Mon Sep 17 00:00:00 2001 From: Mark Cresitello-Dittmar Date: Tue, 2 Mar 2021 14:08:11 -0500 Subject: [PATCH 2/2] Update README.md markdown corrections and adding plot --- .../mcd-implementation/README.md | 21 ++++++++++--------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/usecases/native_frames/mcd-implementation/README.md b/usecases/native_frames/mcd-implementation/README.md index 77c5a60..491217b 100644 --- a/usecases/native_frames/mcd-implementation/README.md +++ b/usecases/native_frames/mcd-implementation/README.md @@ -8,10 +8,11 @@ * Illustrate that the model allows for >1 instance of any given Property + Positions in multiple reference frames + Flux in multiple bands + * Illustrate ability to reconcile Positions in different Frames The data has been annotated using IVOA VO-DML Mapping syntax * one Position using the Measurment model Position with Point coordinate, - which rama automatically converts to an astroPy SkyCoord. + which rama automatically converts to an AstroPy SkyCoord. * one Position using the Mango model LonLatSkyPosition with LonLatPoint coordinate. Annotation was produced using the 'Jovial' modeling toolset (Java). Jovial @@ -66,11 +67,10 @@ sys.stdout.write(" + coord type = %s\n"%str(type(param.measure.coord) )) positions.append(param.measure) ``` - o Found Position in 'icrs' frame - + coord type = - o Found Position in 'GALACTIC' frame - + coord type = - + o Found Position in 'icrs' frame + + coord type = + o Found Position in 'GALACTIC' frame + + coord type = * **Goal: Create AstroPy SkyCoord from LonLatPosition** Note: - the following can form an adapter on LonLatPoint to enable auto-convertion @@ -84,8 +84,8 @@ sys.stdout.write("o coords1: type=%s, frame=%s\n"%(str(type(coords1)), coords1.frame.name )) sys.stdout.write("o coords2: type=%s, frame=%s\n"%(str(type(coords2)), coords2.frame.name )) ``` - o coords1: type=, frame=icrs - o coords2: type=, frame=galactic + o coords1: type=, frame=icrs + o coords2: type=, frame=galactic * **Goal: Convert both to common Frame - client's preferred frame** ``` @@ -94,8 +94,8 @@ sys.stdout.write("o coords1: type=%s, frame=%s\n"%(str(type(coords1_user)), coords1_user.frame.name )) sys.stdout.write("o coords2: type=%s, frame=%s\n"%(str(type(coords2_user)), coords2_user.frame.name )) ``` - o coords1: type=, frame=fk5 - o coords2: type=, frame=fk5 + o coords1: type=, frame=fk5 + o coords2: type=, frame=fk5 * **Goal: Plot the data** Note: Since the original data are positions of the same source in different frames, these should overlap. @@ -122,3 +122,4 @@ plt.show() ``` + ![Figure_1](https://user-images.githubusercontent.com/14201994/109700688-1be4fa00-7b60-11eb-9ea0-a34e46b386b1.png)