1.88. hiClass

Full Name: herschel.hifi.dp.tools.HiClassTask
Alias: hiClass
Type: Jython Task - Jython Task
Import: from herschel.hifi.dp.tools import HiClassTask
Category

HIFI/Conversion

Description

Export HIFI spectra to a FITS file that CLASS can read.

This task is designed to export Data (at least level 0.5: having gone through the instrument pipeline) to a FITS file that CLASS can understand. Datasets, HTP and ObservationContexts can be passed to the task. Passing the ObservationContext will result in all the level 2 data being converted to a CLASS readable FITS file. See the HIFI Data Reduction Guide for more information. Note that this task actually uses the class HiClass which offers more flexibility. Some useful examples are given below.

For a complete documentation of HiClass object, please type:

>>> print herschel.hifi.dp.tools.hiclass_tools.__doc__

Examples

Example 1: Export your data to a FITS file with HiClassTask (see available input data):
HiClassTask()(data = data, fileName = 'myspectrum.fits')
Example 2: Export your data to a FITS file in silent mode (verbose=False):
HiClassTask()(data = data, fileName = 'myspectrum.fits', verbose=False)
Example 3: Export your data to a FITS file with HiClass (see available input data):
h = HiClass()
h.add(data)
h.saveToFits('myspectrum.fits')
Example 4: Export a system temperature spectrum
# You must first provide the Tsys spectrum you want. 
tsys = obs.calibration.getProduct('pipeline-out')\
          .getProduct('Tsys').getProduct('WBS-H')
# Export it like you would do for any product.
HiClassTask()(data = tsys, fileName = 'tsys_WBS-H.fits')
Example 5: Export all the system temperature spectra
h = HiClass()
for backend in ('WBS-H', 'WBS-V', 'HRS-H', 'HRS-V'):
    tsys = obs.calibration.getProduct('pipeline-out')\
              .getProduct('Tsys').getProduct(backend)
    if tsys is None:
        print "Could not retrieve the Tsys in %s." % backend
    else:
        h.add(tsys)
h.saveToFits("mytsys.fits")
Example 6: Export all the levels from an ObservationContext
h = HiClass()
for level_number in ('0', '0_5', '1', '2'):
    level_name = 'level%s' % level_number
    try:
        p = obs.refs[level_name].product
    except AttributeError:
        print "Could not retrieve %s." % level_name
    else:
        h.add(p)
h.saveToFits('my_obs.fits')
Example 7: See what the HiClass Product looks like.
# after the previous example, enter:
prod = h.Prod
# now, look at it with the Dataset Explorer.  
# It is the product exported by FitsArchive. Each dataset in the Product
corresponds to a row in the table of the FITS file.

API details

Properties

AbstractAnnotatable data [INPUT, MANDATORY, default=None]

Data containing HifiSpectrumDatasets. HiClassTask recognizes these types of products:

  • HifiSpectrumDataset

  • HrsSpectrumDataset

  • WbsSpectrumDataset

  • HifiVectorDataset

  • Product

  • ProductRef

  • HashSet

  • HifiTimelineProduct

  • ObservationContext

  • CalFluxHotCold

HiClassTask will navigate as deep as it can into these data, going through references, until it finds HifiSpectrumDataset objects on which HiClassTask ultimately works.

If at any point HiClassTask finds data it cannot handle, then a ValueError exception is raised.

NaNs in the flux columns will be replaced by -1000. That is the only way to blank channels in CLASS as CLASS does not handle flags or NaNs.

String fileName [INPUT, OPTIONAL, default='']

The name of the FITS file (path included) that you wish to generate. If left empty (''), a default value ('hiclass_output.fits') is set. See examples.

HiClass hiClassObj [INPUT, OPTIONAL, default=None]

A HiClass object. It contains a Product which, when exported to FITS, can be understood by CLASS. It also contains methods to insert datasets into that Product (quite a lot of processing and reshaping is required). You don't have to know much about that object to be able to use it. One HiClass object corresponds to one FITS file. You can add as many datasets as you want to this HiClass object before exporting it as a FITS file.

If you leave the task parameter hiClassObj to its default value None, then a HiClass object will be created for you. And you usually don't have to touch it after that.

HiClass hiClassObj [OUTPUT, MANDATORY, default='']

The HiClass object resulting from an export. It is created when the hiClassObj input parameter is left to its default value.

Boolean engineeringMode [INPUT, OPTIONAL, default=false]

Force the access to the calibration tree root. This parameter should be set to true (box checked) if the user has an up-to-date calibration tree and wants to get the following engineering parameters:

  • the chopper position (ELEVATIO)

  • the beam efficiency (BEAMEFF)

  • the forward efficiency (FORWEFF)

Note that accesssing the calibration tree can take some time.

History

  • drabois-22/09/2014
  • New meta-data to propagate in the Class FITS files per default
  • drabois-24/10/2013
  • Allow to write CLASS FITS files on WBS/HRS spectrum datasets right-clicking on them (HIFI-5523, DPUG#22/3)
  • drabois-07/02/2013
  • Improve HiClassTask behaviour:
  • Add verbose checkbox
  • a default filename is provided if the user forgets it
  • append ".fits" to filename if the user forgets it
  • fix a bug with 'dataset' (use instrument meta)
  • drabois-06/04/2011
  • Export system temperature spectrum to CLASS (HIFI-3847)
  • delforge-03/02/2010
  • HiClass now produces the signal and image frequencies in the reference
  • frame of the source (rest frequencies) which is the only one CLASS is
  • supposed to deal with.
  • Two new input parameters were introduced: veloSource and
  • specsys

    . They are used to override the velocity of the source and

  • the reference frame in which the frequencies are expressed in the
  • input dataset. Useful when the proposal or the pipeline is lacking
  • something.
  • delforge-03/02/2010
  • blanking value set to -1000 instead of 1000
  • better exception handling around the code loading the chopper table
  • exports a tsys value for each spectrum
  • specify LSR as a referential for velocity
  • delforge-27/10/2009
  • When exporting an HTP or an ObservationContext, HiClass will try to find a
  • common reference position for all the datasets. (HIFI-2983)
  • delforge-09/10/2009
  • HiClassTask is now visible from Hipe. (HIFI-2983)
  • delforge-11/09/2009
  • First version in hifi.dp.tools.
  • delforge-10/10/2008
  • Creation