{"id":1364,"date":"2015-01-29T15:30:02","date_gmt":"2015-01-30T01:30:02","guid":{"rendered":"http:\/\/www.eaobservatory.org\/jcmt\/?page_id=1364"},"modified":"2023-09-26T17:12:53","modified_gmt":"2023-09-27T03:12:53","slug":"converting-to-class-format","status":"publish","type":"page","link":"https:\/\/www.eaobservatory.org\/jcmt\/instrumentation\/heterodyne\/data-reduction\/reducing-acsis-data\/converting-to-class-format\/","title":{"rendered":"Converting to CLASS format"},"content":{"rendered":"<p><span style=\"color: red\"><br \/>\nTo run the <a href=\"http:\/\/www.iram.fr\/IRAMFR\/GILDAS\/\">GILDAS software<\/a> (CLASS, GREG, etc) in Hilo or at JCMT first type (or enter this in your .login file):<br \/>\n<\/span><\/p>\n<blockquote><p>setenv GAG_ROOT_DIR \/jcmt_sw\/CLASS\/GILDAS<\/p>\n<p>setenv GAG_EXEC_SYSTEM x86_64-redhat6.9-gfortran<\/p>\n<p>source $GAG_ROOT_DIR\/etc\/login<\/p><\/blockquote>\n<p>The latest installed version (February 2018c) can be reached at all 64-bit machines in Hilo and at the JCMT on pueo and ulili.<\/p>\n<p>If you prefer to use CLASS and other Gildas software to reduce your spectra these are the steps to take.<\/p>\n<p>The following assumes that you are using the most recent release of the <a href=\"http:\/\/starlink.eao.hawaii.edu\/starlink\">Starlink<\/a> and <a href=\"http:\/\/www.iram.fr\/IRAMFR\/GILDAS\/\">GILDAS<\/a> software.<\/p>\n<p>If you plan to convert reduced FITS files from the CADC archive, see the bottom of this page.<\/p>\n<h4>Converting single spectra<\/h4>\n<p>First make cubes of the ACSIS data with makecube or ORAC-DR. Note that in some cases (e.g., comet data) the coordinate system is not standard and it might be necessary to add <em>system=&#8217;FK5&#8242;<\/em> to the end of this command to ensure proper conversion.  Also note that the default projection parameters may not be suitable so it might be necessary to add <em>autogrid=true<\/em> (as below) or specify the parameters CROTA, PIXSIZE, REFLAT and REFLON directly &mdash; see the <a href=\"http:\/\/starlink.eao.hawaii.edu\/devdocs\/sun258.htx\/sun258ss39.html\">makecube<\/a> manual for more details of these parameters.<\/p>\n<blockquote><p>makecube file.sdf file-cube.sdf autogrid=true<\/p><\/blockquote>\n<p>Then extract subcubes of dimension 1,1,nspec from the cubes in NDF format and convert these to FITS format.<\/p>\n<p>This can be done with the <a href=\"http:\/\/starlink.eao.hawaii.edu\/devdocs\/sun95.htx\/sun95.html\">kappa<\/a> command <a href=\"http:\/\/starlink.eao.hawaii.edu\/devdocs\/sun95.htx\/sun95ss121.html#Q1-148-589\">ndfcopy<\/a> and the <a href=\"http:\/\/starlink.eao.hawaii.edu\/devdocs\/sun55.htx\/sun55.html\">convert<\/a> command <a href=\"http:\/\/starlink.eao.hawaii.edu\/devdocs\/sun55.htx\/sun55ss14.html#Q1-21-47\">ndf2fits<\/a>.<\/p>\n<p>If you have multi-subsystem observations, where the first subband is in LSB (USB) and another is in USB (LSB), you have to change the sideband in the header of the USB (LSB) cube:<\/p>\n<blockquote><p>kappa<\/p>\n<p>wcsattrib file.sdf set sideband USB (LSB)<\/p><\/blockquote>\n<p>The simplest ways to convert .sdf files to FITS format for Namakanui, RxA3 and RxW (single spectra):<\/p>\n<blockquote><p>convert<br \/>\nndf2fits file.sdf file.fits encoding=&#8221;fits-class&#8221;<\/p><\/blockquote>\n<p>For certain mapping dataset obtained with RxA3, Namakanui or HARP, in order to retain correct spectral units, one might need to follow these steps to extract one single spectrum. The usage of <em>section<\/em> might be necessary. For example, to extract a spectrum from position (1,1) in a map:<\/p>\n<blockquote><p>kappa<br \/>\nndfcopy in=&#8217;file(1,1,)&#8217; out=fileout.sdf exten<br \/>\n.\/<a href=\"http:\/\/www.eaobservatory.org\/JCMT\/spectral_line\/data_reduction\/cubecopy\">cubecopy<\/a> fileout.sdf file_cc.sdf<\/p>\n<p>convert<br \/>\nndf2fits file_cc.sdf file.fits encoding=&#8221;fits-class&#8221;<\/p><\/blockquote>\n<p>The parameter <em>exten<\/em> in <em>ndfcopy<\/em> extracts header arrays (e.g. Tsys, Trec, exposure time) correctly when copying the cubes.<br \/>\n<em>Cubecopy<\/em> copies the cube and updates the median values of the FITS header parameters MEDTSYS, EFF_EXP, and EFF_TIME.<\/p>\n<h4>Converting maps<\/h4>\n<p>To convert maps one needs to do this for all positions in the map.<br \/>\nAt the bottom of this page is an <a href=\"http:\/\/www.eaobservatory.org\/jcmt\/instrumentation\/heterodyne\/data-reduction\/reducing-acsis-data\/converting-to-class-format#converting\">alternative method<\/a> where however some header information is lost.<\/p>\n<p>This is an example of a csh script that finds the dimensions of a cube and extract all spectra:<br \/>\n<a href=\"http:\/\/www.eaobservatory.org\/JCMT\/spectral_line\/data_reduction\/fitsfiles\">fitsfiles<\/a> (Use: .\/fitsfiles ndffilename)<\/p>\n<h4>To CLASS<\/h4>\n<p>These files can be converted into class format<\/p>\n<blockquote><p>%class<\/p>\n<p>LAS90&gt;file out jcmtdata mul (or sin)<\/p>\n<p>LAS90&gt;fits read file.fits<\/p>\n<p>(or alternatively)<\/p>\n<p>LAS90&gt;fits read &#8220;\/dir\/subdir\/file.fits&#8221;<\/p>\n<p>LAS90&gt;write n<\/p><\/blockquote>\n<p>(note: if the scannumber is missing in the fits header one needs to give a number when writing to the output file, or it will be put to 1)<\/p>\n<p>If you have large maps it is useful to do the conversion to class format with a commandfile, e.g.<\/p>\n<blockquote><p>%ls *.fits &gt; files.class<\/p><\/blockquote>\n<p>and then edit files.cfits with your favourite editor from<\/p>\n<blockquote><p>file.fits<\/p><\/blockquote>\n<p>to<\/p>\n<blockquote><p>fits read file.fits<\/p>\n<p>write 1<\/p>\n<p>etc<\/p><\/blockquote>\n<p>then<\/p>\n<blockquote><p>%class<\/p><\/blockquote>\n<p>to start CLASS<\/p>\n<blockquote><p>LAS90&gt;@files.class<\/p><\/blockquote>\n<h4>Problems<\/h4>\n<p>Currently there are some problems with the FITS files converted in this way.<br \/>\nSome header variables don&#8217;t have the expected name in the FITS files.<br \/>\nTo correct this, enter in CLASS before reading the file:<\/p>\n<blockquote><p>LAS90&gt; sic\\symbol OBSNUM SCAN-NUM<br \/>\nLAS90&gt; sic\\symbol NSUBSCAN SUBSCAN<br \/>\nLAS90&gt; sic\\symbol MEDTSYS TSYS<br \/>\nLAS90&gt; sic\\symbol EXP_TIME OBSTIME<br \/>\nLAS90&gt; sic\\symbol LINE NOTAKEY<br \/>\nLAS90&gt; sic\\symbol MOLECULE LINE<\/p><\/blockquote>\n<p>Note:<br \/>\nThe SCAN number is missing (and put to 1 by class) when the ACSIS spectrum is the sum of many spectra; the CLASS parameter NUMBER remains 0.<\/p>\n<p>There is a FITS keyword LINE, but it is empty (CLASS LINE is part of MOLECULE).<br \/>\nThe FITS keyword OBSID (present when the spectrum is from a single observation) causes a warning for unknown reasons.<br \/>\nThe FITS spectrum may contain an extension image with the variance which causes a warning. If this is a problem it can be removed with a KAPPA command from the sdf file, e.g. erase file_cc.sdf.variance<\/p>\n<p>Other header parameters which are missing are:<\/p>\n<blockquote><p>tau (not calculated for ACSIS data)<br \/>\nweather parameters<br \/>\nbeameff<br \/>\nforweff<\/p><\/blockquote>\n<p>All class spectra will have the observed position in the header<br \/>\n(offsets are 0 0 for every position in a map).<br \/>\nSo in class one may want to modify the positions:<br \/>\nIn order to do that one has to modify the projection to &#8216;radio&#8217; (7).<br \/>\nset var pos write<br \/>\nlet proj 7<br \/>\nmodi pos hh:mm:ss.ss dd:mm:ss<\/p>\n<h4 id=\"converting\">Converting cubes<\/h4>\n<p>It is possible to convert a FITS format cube to a GDF file and extract CLASS format spectra from the GDF file.<br \/>\nOne can use the CLASS commandfile <a href=\"http:\/\/www.eaobservatory.org\/JCMT\/spectral_line\/data_reduction\/jcmt2class.class\">jcmt2class.class<\/a> after converting the SDF file to FITS format:<\/p>\n<blockquote><p>convert<br \/>\nndf2fits cube.sdf cube.fits<br \/>\n%class<br \/>\nLAS90&gt;@jcmt2class cube.fits<\/p><\/blockquote>\n<p>This will make a GDF file cube.gdf and a file cube.jcmt with the CLASS format spectra (it uses the CLASS command lmv to extract the spectra from the cube).<br \/>\nHowever the system temperature and integration time in the CLASS headers are the median values within the cube. If one needs exact values for these parameters the earlier described method has to be followed.<\/p>\n<h4>Note<\/h4>\n<p>Because of the limitations of the CLASS headers, observations made with very large radial velocities will have incorrect velocities and velocity resolutions in CLASS. It is recommended in such cases to observe with a calculated sky frequency and velocity 0 km\/s.<\/p>\n<p>This can also be reached using Starlink Kappa commands (before converting to CLASS):<\/p>\n<blockquote><p>Kappa<br \/>\nwcsattrib file.sdf set RestFreq frequency<br \/>\nwcsattrib file.sdf set SourceVel 0.0<\/p><\/blockquote>\n<p>where <em>frequency<\/em> is the rest frequency corrected for the assumed radial velocity (default is LSR velocity) of the source.<\/p>\n<h4>Reduced archive data<\/h4>\n<p>When converting reduced FITS files obtained from the CADC archive first convert the FITS file to NDF format:<\/p>\n<blockquote><p>Convert<br \/>\nfits2ndf file.fits file.sdf<\/p><\/blockquote>\n<p>Then proceed as explained above.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>To run the GILDAS software (CLASS, GREG, etc) in Hilo or at JCMT first type (or enter this in your .login file): setenv GAG_ROOT_DIR \/jcmt_sw\/CLASS\/GILDAS setenv GAG_EXEC_SYSTEM x86_64-redhat6.9-gfortran source $GAG_ROOT_DIR\/etc\/login The latest installed version (February 2018c) can be reached at all 64-bit machines in Hilo and at the JCMT on\u2026 <a class=\"continue-reading-link\" href=\"https:\/\/www.eaobservatory.org\/jcmt\/instrumentation\/heterodyne\/data-reduction\/reducing-acsis-data\/converting-to-class-format\/\">Continue reading<\/a><\/p>\n","protected":false},"author":10,"featured_media":0,"parent":630,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":[],"_links":{"self":[{"href":"https:\/\/www.eaobservatory.org\/jcmt\/wp-json\/wp\/v2\/pages\/1364"}],"collection":[{"href":"https:\/\/www.eaobservatory.org\/jcmt\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.eaobservatory.org\/jcmt\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.eaobservatory.org\/jcmt\/wp-json\/wp\/v2\/users\/10"}],"replies":[{"embeddable":true,"href":"https:\/\/www.eaobservatory.org\/jcmt\/wp-json\/wp\/v2\/comments?post=1364"}],"version-history":[{"count":45,"href":"https:\/\/www.eaobservatory.org\/jcmt\/wp-json\/wp\/v2\/pages\/1364\/revisions"}],"predecessor-version":[{"id":12965,"href":"https:\/\/www.eaobservatory.org\/jcmt\/wp-json\/wp\/v2\/pages\/1364\/revisions\/12965"}],"up":[{"embeddable":true,"href":"https:\/\/www.eaobservatory.org\/jcmt\/wp-json\/wp\/v2\/pages\/630"}],"wp:attachment":[{"href":"https:\/\/www.eaobservatory.org\/jcmt\/wp-json\/wp\/v2\/media?parent=1364"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}