Presentation is loading. Please wait.

Presentation is loading. Please wait.

The VAO is operated by the VAO, LLC. VO Application Libraries Mike Fitzpatrick NOAO.

Similar presentations


Presentation on theme: "The VAO is operated by the VAO, LLC. VO Application Libraries Mike Fitzpatrick NOAO."— Presentation transcript:

1 The VAO is operated by the VAO, LLC. VO Application Libraries Mike Fitzpatrick NOAO

2 May 18, 2010IVOA Interop – Victoria, 2010 22 Libraries In order to VO-enable legacy applications, they must be able to use VO standards and protocols. In order to reach as many applications as possible, we cannot be limited to a specific language or toolkit. Start with the basics of an application toolkit: VOTable- lingua franca of the VO SAMP- play nice with other tools VOEvent- some seem to like it VOClient- get the data

3 May 18, 2010IVOA Interop – Victoria, 2010 33 Development Concepts C-based code Use SWIG to create other language interfaces (Python, Java, etc) Hand-code Fortran (and IRAF/SPP) interface Hide the underlying complexity from the user/developer E.g. an application developer wants to use SAMP to send/receive messages, they shouldnt need to implement the full spec or know XML-RPC Be Language-Neutral E.g. Dont return a votable structure, use handles to more complex objects VO Protocols change and evolve Change the library, not every application using it

4 May 18, 2010IVOA Interop – Victoria, 2010 44 libVOTable Full Read/Write Capability Lenient Parser Only requires proper XML to read Can be used as a validating parser VOTable v1.2 compliant on output SAX-based parser, DOM interface Fast lookup of data tables Provides low-level access to document structure Self-contained, i.e. no need for parser lib VOTables now accessible to Fortran applications

5 May 18, 2010IVOA Interop – Victoria, 2010 55 libVOTable main (int argc, char **argv) { vot = openVOTABLE (argv[1]); res = vot_getRESOURCE (vot); tab = vot_getTABLE (res); data = vot_getDATA (tab); tdata = vot_getTABLEDATA (data); for (field=vot_getFIELD(tab); field; field = vot_getNext(field)) name = vot_getAttr (field, "name) } for (tr=vot_getTR (tdata); tr; tr=vot_getNext(tr)) { for (td=vot_getTD(tr),i=0; td; td=vot_getNext(td),i++) { printf ("%s", ((s = vot_getValue (td)) ? s : "") ); }

6 May 18, 2010IVOA Interop – Victoria, 2010 66 libVOTable Print all the PARAM elements in a table with a single RESOURCE a) Use the low-level interface dealing with document structure res = vot_getRESOURCE (vot) for (p = vot_getChild (res); p; p = vot_getSibling (p)) { if (vot_typeOf (p) == TY_PARAM) printf ("PARAM name=%s value=%s\n", vot_getAttr(p, "name"), vot_getAttr(p, "value")) } b) Use the common hi-level interface res = vot_getRESOURCE (vot) for (p = vot_getPARAM (res); p; p = vot_getNext (p)) { printf ("PARAM name=%s value=%s\n", vot_getAttr(p, "name"), vot_getAttr(p, "value")) }

7 May 18, 2010IVOA Interop – Victoria, 2010 77 libVOTable vot1 = vot_openVOTABLE (in1); /* Parse the files */ vot2 = vot_openVOTABLE (in2); res1 = vot_getRESOURCE (vot1);/* Get RESOURCEs */ res2 = vot_getRESOURCE (vot2); vot3 = vot_openVOTABLE (out_fname);/* Open output */ vot_attachNode (vot3, res1); /* Concat tables */ vot_attachNode (vot3, res2); vot_writeVOTable (vot3, stdout); /* Write it out */ vot_closeVOTABLE (vot1); vot_closeVOTABLE (vot2); if (vot3) vot_closeVOTABLE (vot3);

8 May 18, 2010IVOA Interop – Victoria, 2010 88 libVOEvent Similar to VOTable parser (shared code) Full Read/Write Capability Lenient Parser Only requires proper XML to read Can be used as a validating parser VOEvent v1.11 compliant on output SAX-based parser, DOM interface Provides low-level access to document structure Self-contained, i.e. no need for parser lib VOEvent now accessible to Fortran applications (!?!) Hides the complexity of VOEvent from the user

9 May 18, 2010IVOA Interop – Victoria, 2010 99 libVOEvent The myth: VOEvent is a lightweight, simple format i.e.

10 May 18, 2010IVOA Interop – Victoria, 2010 10 libVOEvent ivo://nasa.gsfc.tan/gcn VO-GCN Scott Barthelmy +1-301-286-3106 scott.barthelmy@nasa.gov 2010-05-18T06:19:02 This VOEvent message was created with GCN VOE version: 1.1 11mar10 The Sun and Moon values are valid at the time the VOEvent XML message was created. Type=97: The Swift-BAT instrument quick-look position notice. 2010-05-18T06:18:26.56

11 May 18, 2010IVOA Interop – Victoria, 2010 11 libVOEvent RA Dec 311.1619 40.1699 0.0500 The RA,Dec coordinates are of the type: source_object. Swift Satellite, BAT Instrument GRB 100518 process.variation.burst;em.gamma Twice as many elements as VOTable Addition of ephemeris, time-series, etc wont help No general-purpose code available

12 May 18, 2010IVOA Interop – Victoria, 2010 12 libVOEvent Sample Low-level interface: voe = voe_openVOEvent (str|fname, &version, &ivorn) voe_closeVOEvent (voe) who = voe_getWho (voe) str = voe_getAuthorIVORN (who) auth = voe_getAuthor (who) str = voe_getTitle (auth) str = voe_getShortName (auth) str = voe_getLogoURL (auth) str = voe_getContactName (auth) str = voe_getContactEmail (auth) str = voe_getContactPhone (auth) str = voe_getContributor (auth):

13 May 18, 2010IVOA Interop – Victoria, 2010 13 libVOEvent Sample Hi-level interface: who_str = voe_getWho (voe) what_str = voe_getWhat (voe) when_str = voe_getWhenWhere (voe) how_str = voe_getHow (voe) why_str = voe_getWhy (voe) voe_setWho (voe, title, shortName, contactName, ivorn) voe_setWhat (voe, name[], value[], ucd[]) voe_setWhenWhere (voe, obsName, ra, dec, err) voe_setHow (voe, refUri, type, name) voe_setWhy (voe, name, concept, probability)

14 May 18, 2010IVOA Interop – Victoria, 2010 14 libSAMP Client-side middleware to send/receive messages Based on XMLRPC-C w/ simpler interface Distributed as part of the library No separate Hub implementation High-level interface for easy use

15 May 18, 2010IVOA Interop – Victoria, 2010 15 libSAMP Client-side middleware to send/receive messages Based on XMLRPC-C w/ simpler interface Distributed as part of the library No separate Hub implementation Hides Hub interaction, no need for user to be aware High-level interface for easy use Low-level interface for finer control

16 May 18, 2010IVOA Interop – Victoria, 2010 16 libSAMP samp = sampInit (appName, descr) sampClose (samp) stat = sampStartup (samp sampShutdown (samp) samp_setMetadata (samp, field, value) samp_setSubscription (samp, mtype, handler) samp_setCallMode (samp, sync|async) samp_setReplyCallback (samp, func) samp_setResponseCallback (samp, func) stat = samp_replyStatus (samp)

17 May 18, 2010IVOA Interop – Victoria, 2010 17 libSAMP Example Code: samp = sampInit (name, descr); /* initialize the interface */ samp_setMetadata (samp, "samp.icon.url", "none) samp_setMetadata (samp, "echo.test", "myValue"); /* Subscribe to various message types. */ samp_setSubscription (samp, "samp.app.ping", NULL); samp_setSubscription (samp, image.*", imageHandler); samp_setSubscription (samp, table.*", tableHandler); sampStartup (samp); /* Startup */.... do other stuff sampShutdown (samp);

18 May 18, 2010IVOA Interop – Victoria, 2010 18 libSAMP High-level message sending: msg_id = samp_tableLoadFITS (recip, url, id, name[, method]) msg_id = samp_tableLoadVOTable (recip, url, id, name[, method]) msg_id = samp_tableHighlightRow (recip, url, id, row[, method]) msg_id = samp_tableSelectRowList (recip, url, id, rowlist[, method]) msg_id = samp_imageLoadFITS (recip, url, id, name[, method]) ::::: reply = samp_getReply (msg_id)

19 May 18, 2010IVOA Interop – Victoria, 2010 19 libSAMP Dealing with Maps / Lists map = samp_newMap () samp_freeMap (Map map) samp_setStringInMap (Map map, char *key, char *value) samp_setMapInMap (Map map1, char *key, Map map2) samp_setListInMap (Map map, char *key, List list) str = samp_getStringFromMap (Map map, char *key) map = samp_getMapFromMap (Map map, char *key) list = samp_getListFromMap (Map map, char *key)


Download ppt "The VAO is operated by the VAO, LLC. VO Application Libraries Mike Fitzpatrick NOAO."

Similar presentations


Ads by Google