Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FITS2NDF creates SMURF extension with the wrong type #60

Open
grahambell opened this issue Jun 24, 2017 · 5 comments
Open

FITS2NDF creates SMURF extension with the wrong type #60

grahambell opened this issue Jun 24, 2017 · 5 comments

Comments

@grahambell
Copy link
Contributor

FITS2NDF doesn't seem to correctly identify the SMURF extension, so converting reduced SCUBA-2 data to FITS and back (as the JSA does to generate co-adds) I see this kind of HDS structure:

   MORE           <EXT>           {structure}
      FITS(322)      <_CHAR*80>      '...'
      SMURF          <QUALITY_NAMES>   {structure}
         QUALITY_NAMES  <QUALITY_NAMES>   {structure}
            LAST_USED      <_INTEGER>      2

Then because the SMURF extension's type is QUALITY_NAMES (rather than SMURF_EXT), NDF2FITS doesn't recognize it when converting the co-add back to FITS format. It does:

                  SMURF = XTYPE .EQ. 'SMURF' .OR.
     :                    XTYPE .EQ. 'SMURF_EXT'

So the SMURF extension is written out as binary tables rather than via COF_SMURF.

I'm not sure if COF_F2NDF's special handling of SMURF files via COF_SMFIM would help generate the correct type SMURF extension in the first palce -- I didn't look at that in detail, but COF_SPEC attempts to identify SMURF files like this:

      ELSE IF ( TELPRE .AND. TELESC .EQ. 'JCMT' .AND.
     :          INSPRE .AND. INSTRU .EQ. 'HARP'  ) THEN
         NAME = 'SMURF'
      END IF

so it won't identify SCUBA-2 observations as being from SMURF.

In commit cf49433 (on the 2015A-legacy branch), I added a couple of temporary checks for ways the SMURF extension was being created for the reduced SCUBA-2 FITS files I had to hand, to set the type to SMURF_EXT.

@dsberry
Copy link
Member

dsberry commented Jun 26, 2017

COF_SPEC is definitely wrong. I've changed it to use Malcolm's own suggestion of looking for FITS extensions that refer to ".MORE.SMURF"

This doesn't solve the whole problem since the correct HDS type for the SMURF extension (i.e. SMURF_EXT) is not recorded in the FITS file anywhere. What does seems to work though is modifying cof_smurf.f so that it always call cof_wstr regardless of the value of NONNDF. This causes an extra dummy FITS extension to be added to the FITS file that does contain the real type "SMURF_TYP" for the extension, and this extension is used by fits2ndf to recreate the correct type. But would including this extra FITS extension have implications for CADC? The headers for it look like this:

XTENSION= 'BINTABLE' / binary table extension
BITPIX = 8 / 8-bit bytes
NAXIS = 2 / 2-dimensional binary table
NAXIS1 = 4 / width of table in bytes
NAXIS2 = 1 / number of rows in table
PCOUNT = 0 / size of special data area
GCOUNT = 1 / one data group (required keyword)
TFIELDS = 1 / number of fields in each row
TTYPE1 = 'DUMMY_FOR_STRUC' / label for field 1
TFORM1 = '1J ' / data format of field: 4-byte INTEGER
TNULL1 = -2147483648 / Starlink bad value
EXTNAME = 'OUT.MORE.SMURF' / name of this binary table extension
EXTLEVEL= 3 / Level in the hierarchical structure
EXTTYPE = 'SMURF_EXT' / HDS data type of the primitive object
EXTSHAPE= '0 ' / Shape of the hierarchical structure
END

There's an example fits file at /home/dberry/out.fit.gz at Hilo.

@MalcolmCurrie
Copy link
Contributor

MalcolmCurrie commented Jun 26, 2017 via email

@grahambell
Copy link
Contributor Author

This causes an extra dummy FITS extension [...] But would including this extra FITS extension have implications for CADC?

That shouldn't be a problem for CADC. We currently just assume we know what the primary HDU and first extension are for most files in the JSA. (Those typically being "science" and noise respectively.) Even if it were a problem, since we now run all the ingestion software at EAO in Hilo, we could easily make any necessary changes.

@dsberry
Copy link
Member

dsberry commented Jun 27, 2017

Thanks @MalcolmCurrie - I'll leave it to you then.

@MalcolmCurrie
Copy link
Contributor

MalcolmCurrie commented Jun 28, 2017 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants