-
Notifications
You must be signed in to change notification settings - Fork 1
How to create an instance of a CAOM2 Observation from an xml file
-
This description assumes a working knowledge of python. Prefer python3, please.
-
This description assumes a working directory location, where all files discussed are placed.
-
This description assumes you have a CADC account.
-
This description uses the parameter 'test_obs.xml'. Replace this value with real file names when executing the commands.
-
The instance will be created in the CAOM2 sandbox.
-
Install the following python dependencies:
pip install caom2repo
-
Get credentials organized. The examples assume the use of a .netrc file. The .netrc file content should include the following, with cadcusername and cadcpassword replaced with your CADC username and password values:
machine sc2.canfar.net login cadcusername password cadcpassword
-
The caom2-repo client also supports username/password and X509 certificates. If you want to use X509 certificates use the --cert parameter instead of the -n parameter in all the commands.
-
Test the install. Commands are case-sensitive.
caom2-repo read -n --resource-id ivo://cadc.nrc.ca/sc2repo MeerKAT abc
-
This will report an error:
Client Error: Not Found for url: http://sc2.canfar.net/sc2repo/auth-observations/MEERKAT/abc.
-
Create a file named 'test_obs.xml' in the working directory with the CAOM2 metadata content. Use the caom2 library that came with the caom2repo package to create the various CAOM2 entities and attributes, as parsed from MeerKAT hdf5 files. For example (there's more than are listed here):
from caom2 import Observation, SimpleObservation, CompositeObservation, Plane, Artifact, DataProductType
-
Go here for examples of using the caom2 library in python code.
-
Run caom2-repo.
caom2-repo create -n --resource-id ivo://cadc.nrc.ca/sc2repo test_obs.xml
-
The output from this command should be:
-
Everything after this is making refinements to the mapping between file content and CAOM2 instance members. However, caom2-repo is particular about it's ids, so after the first successful call to create, do this:
caom2-repo read -n --resource-id ivo://cadc.nrc.ca/sc2repo MeerKAT test_obs > test_obs_read.xml
-
There should be a file named test_obs_read.xml on disk. It will be different from test_obs.xml, because the service generates a parallel set of keys that must be honoured. Use this xml as the input to further modifications of the CAOM2 instance, or the caom2-repo create command will fail.
-
After you've generated this output file, use the following command to repeatedly make and view changes to the mapping between the MeerKAT data and the CAOM2 instance:
caom2-repo update -n --resource-id ivo://cadc.nrc.ca/sc2repo test_obs.xml
-
Go to http://sc2.canfar.net/search, enter 'test_obs' into the 'Observation ID' search field, click search, then click the 'test_obs' link in the 'Obs. ID'. This will display the details of the CAOM2 instance for the 'test_obs' in a new tab.