Cal Library for On-the-fly Calibration
An overview of the motivation for and use of the calibration library file can be found in the attached document, prepared for CASA Release 4.4:
2. Cal Library Parser
The CalLibrary parser code has been added in code/synthesis/CalLibrary. The parser uses Bison and Flex so these packages are now required to build the code tree.
- CalLibraryGram.ll - Flex file
- CalLibraryGram.yy - Bison file
- CalLibraryParse.cc, .h - methods called by Bison to build output Record
- CalLibraryTools.cc, .h - callibSetParams and CalLibrary parse commands
To invoke the parser:
Record callibRec = callibSetParams(calLibrary);
The calLibrary String argument can be a filename (fully qualified path) or calibration instructions separated by a comma for each caltable. The parser's input is always a string. A casa Record is returned.
- CalLibraryParse block diagram:
- callibSetParams argument is a filename:
- The file is opened and lines (terminated with "\n") are concatenated into a single string.
- callibSetParams argument is a string of one or more calibration instruction sets, corresponding to the contents of a cal library file:
"caltable='ngc5921.bcal' calwt=True tinterp='nearest'"
"caltable='ngc5921.bcal' calwt=True tinterp='nearest', caltable='ngc5921.fluxscale' calwt=True tinterp='nearest' fldmap='nearest'" (list of strings joined with a comma separator into a single string)
2.1 Future plans
- A new class will be developed by George Moellenbrock to hold the calibration instructions. This class will have a constructor or method to accept a Record and store the specified instructions, along with providing consistency checks. There will also be a way to validate the cal library without having to run a tool such as applycal or plotms.
- Cal Library parser v2a:
- FInally, the parser will be modified to parse the cal library file/string into the new class, without the interim step of creating a Record.
- Cal Library parser v3:
2.2 Parser use in plotms
- Initially in release 4.5 development, the plotms 'callib' argument is a string or list of strings:
- The filename string can be set as the plotms callib argument or using the GUI file browser on the Calibration tab
- The callib argument string can contain calibration instructions
- The list of instruction strings is converted in python to a comma-separated single string and passed to plotms_cmpt
- The callib String is stored in the PlotMSCalibration class. When the accessor PlotMSCalibration::callibRec() is called, the callibSetParams function is called to use the parser as described above, and the resulting Record returned. Plotms inserts this Record into the MSTransformIteratorFactory configuration Record as in 4.4.
- Later in 4.5 development, the callib string will be passed to the iterator factory in the configuration Record. Parsing the string into a Record will happen when the Calibrater class needs to process the instructions, so plotms will no longer invoke the parser. In fact, all future clients of the cal library will not need to know about the parser but will pass an appropriate string down to the Calibrater.
- MSTransformManager, LayeredVI2Factory, CalibratingVi2FactoryI, and possibly other code, will need to be modified to accept a String rather than a Record to set up a calibrating VI2.
2.3 Testing the parser
- A test program tCalLibraryParse has been developed in synthesis/CalLibrary/test.
- To compile this test, in code/build type "make tCalLibraryParse". The executable will be in code/build/synthesis/tCalLibraryParse.
- To run the regression test with saved calibration instructions (a string, multiple strings, and a file), just run
tCalLibraryParse. The resulting Records will be checked for number of fields and various parameter values.
- To test a string filename or calibration instructions, run the test with an optional filename or string:
tCalLibraryParse "caltable='ngc5921.bcal' calwt=False tinterp='nearest'"
- For these user-input tests, the resulting Record will be printed to standard output.