include include "register.h" # crdtyp -- Determines if co-ordinate system is linear or spherical # # Version 1.1B 20-MAY-85 14:53:12 BALL Modifications for RA-DEC(like FINDROT) # 1-Sep-92 R.L. WILLIAMSON II Modified for use in STSDAS # 21-JAN-93 R.L. Williamson II Converted to SPP # # Description: # ------------ # This routine examines the supplied value of the character string CTYPE # and attempts to match these against the FITS SUGGESTED VALUES as # in the original FITS document. Also allowed are certain extensions to # these which will describe the projection type. These values are: # # First Coord Second Coord Description # ---------------------------------------------------------------------- # 'RA ' 'DEC ' Right Ascension and Declination # 'LL ' 'MM ' Tangent plane (LL=East-West) # 'GLON ' 'GLAT ' Galactic longitude and latitude # 'ELON ' 'ELAT ' Ecliptic longitude and latitude # # It is anticipated that the extensions will be of the form, e.g. 'RAxxxxxx' # where the xxxxxx is some string that indicates how the unit deviates from # the standard, e.g. units not degrees, a different projection, etc. etc. # This module will ignore any such extensions by checking, e.g. only the # first two characters for 'RA', the first four for 'GLAT', and so on. # # # Inputs: # ------- # Number_of_axes # Co_ordinate_type_array # # Outputs: # -------- # Axis_Identification # Linear_or_spherical_flag # Status # # # Set the Linear or Spherical flag to Linear # . # IF the Number_of_axes is outside the permitted range # Issue Fatal error message # . # ELSEIF there is only one axis # Set Axis_Identification to one # RETURN # ELSEIF there is more than one axis # . # Initialize the longitude_found and latitude_found flags to FALSE # Initialize Axis_Identification to zero # . # DO for each axis or until both of the above flags are set # . # IF the Coordinate is a longitude-like unit # IF the longitude was already found # Abort this procedure # } # Set the longitude_found flag TRUE # Set Axis_Identification to current value # . # ELSEIF the Coordinate is a latitude-like unit # IF the latitude was already found # Abort this procedure # } # Set the latitude_found flag TRUE # Set Axis_Identification to current value # ELSE # Set Axis_Identifi#ation to current value # } # ENDDO # . # IF both the longitude and latitude were found # Set the Linear or Spheri#al flag to Spherical # . # } (Spherical?) # # IF both the first and second element of Axis_Identification have not / # been assigned then # DO for each axis # Assign Axis_Identification = current axis number # ENDDO # ELSEIF either the first or second element of Axis_Identification has not / # been assigned then # CALL Put Error Message ... warning # } # . # } (Appropriate number of axes?) # . # RETURN # END # # # #------------------------------------------------------------------------------ procedure crdtyp (naxis, ctype, rotaxes, linear,status) int status # (O) Returned status, usually OK int naxis # (I) Number of axes in relevant file int rotaxes[naxis] # (I) Axis identification number int i,l # (L) Local loop index char ctype[SZ_CTYPE,naxis] # (I) Co-ordinate type string(s) char ctemp[SZ_CTYPE] # (L) Temporary storage for CTYPE (I) char context[SZ_LINE] # (L) error string bool linear # (O) Linear or Spherical flag bool lat_found # (L) Local latitude_found flag bool long_found # (L) Local longitude_found flag define termin_ 10 #Functions int strncmp() string duplat "Duplicate latitude-like co-ordinate found " string nosense "Warning! Could not make sense out of CTYPE: " begin status = OK # Assume non-spherical as default linear = true if (naxis < 1 || naxis > 4) { call error (1, "Illegal NAXIS found: not between 1 and 4!") # --- check for NAXIS = 1 first } else if (naxis == 1) { rotaxes(1) = 1 return # --- Now check for more complex cases } else if (naxis > 1) { lat_found = false long_found = false # Initialize values; check later # to see if they have changed rotaxes(1) = 0 rotaxes(2) = 0 # Initial index for non-RA/DEC axes l = 3 do i = 1, naxis { call strcpy (ctype[1,i], ctemp, SZ_CTYPE) call strlwr(ctemp) if (strncmp(ctemp,"ra",2) == 0 || strncmp(ctemp,"ll",2) == 0 || strncmp(ctemp,"glon",4) == 0 || strncmp(ctemp,"elon",4) == 0) { if (long_found) { call strcpy (duplat, context,SZ_LINE) call strcat (ctemp, context,SZ_LINE) call error(1, context) } long_found = true rotaxes(1) = i } else if (strncmp(ctemp,"dec",3) == 0 || strncmp(ctemp,"mm",2) == 0 || strncmp(ctemp,"glat",4) == 0 || strncmp(ctemp,"elat",4) == 0) { if (lat_found) { call strcpy (duplat, context,SZ_LINE) call strcat (ctemp, context,SZ_LINE) call error(1, context) # LAT_FOUND check } lat_found = true rotaxes(2) = i } else { rotaxes(i) = l l = l + 1 # CTEMP check against standard types of co-ord. } # LOOP OVER ALL naxis } if (long_found && lat_found) { linear = false } #--Both zero (initial garbage values) implies the coordinates are not # RA,Dec but may be e.g. rectangular. # One zero and the other not zero implies CTYPE is messed up. if (rotaxes(1) == 0 && rotaxes(2) == 0) { call eprintf("Coords assumed to be rectangular\n") status = RECT do i = 1, naxis { rotaxes(i) = i } } else if (rotaxes(1) == 0 || rotaxes(2) == 0) { call strcpy (nosense, context,SZ_LINE) do i = 1, naxis { call strcat (ctype[SZ_CTYPE,i], context,SZ_LINE) } call eprintf(context) status=NOSENS } # naxis TEST if-BLOCK } end