Skip to content

Commit

Permalink
smurf: Translate GSD frontend string to the real instrument name
Browse files Browse the repository at this point in the history
It turns out that GSD frontend strings are not very consistent
with the worst offender being the switch of RXB3CU to RXB instead
of just using RXB3.

This mainly affects the B-band instruments and RxW now gets the
band appended to the instrument name to be consistent with ACSIS
usage.

A full table of instrument history is included in the routine
gsdac_getRealInstrumentName.c
  • Loading branch information
timj committed Jul 28, 2013
1 parent 642d9b9 commit 25c1b74
Show file tree
Hide file tree
Showing 4 changed files with 239 additions and 5 deletions.
1 change: 1 addition & 0 deletions applications/smurf/libgsd/Makefile.am
Expand Up @@ -12,6 +12,7 @@ gsdac_getDASFlag.c \
gsdac_getDateVars.c \
gsdac_getGSDVars.c \
gsdac_getMapVars.c \
gsdac_getRealInstrumentName.c \
gsdac_getRecepNames.c \
gsdac_getSampleMode.c \
gsdac_getStartIdx.c \
Expand Down
10 changes: 10 additions & 0 deletions applications/smurf/libgsd/gsdac.h
Expand Up @@ -61,6 +61,8 @@
* Add gsdac_printHdr.
* 2008-04-22 (JB):
* Add gsdac_flagBad.
* 2013-07-28 (TIMJ):
* Add gsdac_getRealInstrumentName
* {enter_further_changes_here}
* Copyright:
Expand Down Expand Up @@ -280,6 +282,14 @@ mapVars *mapVars, /* map/chop/scan variables (given and returned) */
int *status /* global status (given and returned) */
);

void gsdac_getRealInstrumentName
(
const gsdVars *gsdVars, /* GSD headers and arrays (given) */
char * instrume, /* Buffer to receive instrument name (given and returned) */
size_t instrumelen, /* Size of instrume (given) */
int *status /* global status (given and returned) */
);

void gsdac_getRecepNames
(
const gsdVars *gsdVars, /* GSD headers and arrays (given) */
Expand Down
215 changes: 215 additions & 0 deletions applications/smurf/libgsd/gsdac_getRealInstrumentName.c
@@ -0,0 +1,215 @@
/*
*+
* Name:
* gsdac_getRealInstrumentName
* Purpose:
* Calculate the real instrument name based on heuristics
* Language:
* Starlink ANSI C
* Type of Module:
* ADAM A-task
* Invocation:
* gsdac_getRealInstrumentName( const gsdVars * gsdVars, char * instrume,
* size_t instrumelen, int * status );
* Arguments:
* gsdVars = const gsdVars* (Given)
* GSD headers and arrays
* instrume = char * (Given and Returned)
* Buffer to receive normalized instrument name.
* instrumelen = size_t (Given)
* Length of instrume buffer.
* status = int* (Given and Returned)
* Pointer to global status.
* Description:
* Determines the actual receiver name. The receiver name is sometimes
* incorrect in the GSD headers where a generic name can be used or the
* same instrument can be rebranded. See the notes for details. If we do
* not recognize the input string we trigger an error. This allows us to
* deal with unexpected cases rather than letting them sneak into the
* converted files.
* Authors:
* Tim Jenness (JAC)
* {enter_new_authors_here}
* History:
* 2013-07-28 (TIMJ):
* Original.
* Notes:
* Here is the history of GSD heterodyne instruments and how they should
* be translated to real instrument names:
*
* MPI: 2000-04 to 2003-02 E-band receiver commonly referred to as
* MPIRE but we will call it MPIRXE
* RXA: 1989-02 to 1992-05
* RXA2: 1992-03 to 1999-01
* RXA3I:1998-12 until the ACSIS era but is now called RXA3
* (Intermediate status was retracted)
* RXB: This name was used for the first B receiver and oddly the
* rebranded RXB3. From 1989-02 to 1990-10 this was RXB
* and from 1997-05 it was really RXB3.
* RXB2: 1990-10 to 1993-11
* RXB3: 1990-11 to 1996-12-01. This was really RXB3I (intermediate)
* RXB3CU: 1996-12-05 to 1997-06-17. Common-Used was dropped and this
* was renamed RXB (a mistake). We now refer to it as RXB3.
* RXC: 1989-06 to 1993-01
* RXC2: 1993-05 to 1998-07
* RXG: 1990-07 to 1995-05
* RXW: 1998-07 to ACSIS era. Will be renamed to RXWC and RXWD to be
* consistent with RXW naming for ACSIS.
*
* So the order using modern names is:
*
* MPIRXE: 2000-04 to 2003-02
* RXA: 1989-02 to 1992-05
* RXA2: 1992-03 to 1999-01
* RXA3: 1998-12 to present
* RXB: 1989-02 to 1990-10
* RXB2: 1990-10 to 1993-11
* RXB3I: 1990-11 to 1996-12
* RXB3: 1996-12 to 2006-01 (dual channel)
* RXC: 1989-06 to 1993-01
* RXC2: 1993-05 to 1998-07
* RXWC/D: 1998-07 to 2005-08 (dual channel)
* RXG: 1990-07 to 1995-05
* Copyright:
* Copyright (C) 2013 Science and Technology Facilities Council.
* All Rights Reserved.
* Licence:
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 3 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be
* useful,but WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this program; if not, write to the Free
* Software Foundation, Inc., 51 Franklin Street,Fifth Floor, Boston,
* MA 02110-1301, USA
* Bugs:
* {note_any_bugs_here}
*-
*/

/* Standard includes */
#include <stdio.h>
#include <string.h>
#include <ctype.h>

/* STARLINK includes */
#include "sae_par.h"
#include "mers.h"
#include "star/one.h"
#include "f77.h"

/* SMURF includes */
#include "gsdac.h"

void
gsdac_getRealInstrumentName( const gsdVars *gsdVars, char * instrume,
size_t instrumelen, int *status ) {

char gsdName[MAXSTRING+1]; /* Local name of GSD frontend. Nul terminated */
size_t i;

if (*status != SAI__OK) return;

/* initialise */
instrume[0] = '\0';

/* Take local copy of frontend so that we can be sure it
has a trailing Nul and we can upper case it. */
cnfImprt( gsdVars->frontend, MAXSTRING, gsdName );

/* Ensure that the instrument is upper case (it should be) */
i = 0;
while ( gsdName[i] ) {
gsdName[i] = toupper( gsdName[i] );
i++;
}

/* Ensure that we have removed trailing whitespace as we want
to do direct comparisons so that RXB3 and RXB3CU are different */
for (i=0; i<MAXSTRING; i++) {
if ( gsdName[i] == ' ' ) {
gsdName[i] = '\0';
break;
}
}

/* Now go through each frontend string and translate */
if ( strcmp( gsdName, "MPI" ) == 0 ) {

one_strlcpy( instrume, "MPIRXE", instrumelen, status );

} else if ( strcmp( gsdName, "RXA3I" ) == 0 ) {

one_strlcpy( instrume, "RXA3", instrumelen, status );

} else if ( strcmp( gsdName, "RXB" ) == 0 ) {

/* Two cases: Before 1995 this is RXB and after it is RXB3. */

if ( gsdVars->obsUT1d < 1995.0 ) {
one_strlcpy( instrume, "RXB", instrumelen, status );
} else {
one_strlcpy( instrume, "RXB3", instrumelen, status );
}

} else if ( strcmp( gsdName, "RXB3" ) == 0 ) {

one_strlcpy( instrume, "RXB3I", instrumelen, status );

} else if ( strcmp( gsdName, "RXB3CU" ) == 0 ) {

one_strlcpy( instrume, "RXB3", instrumelen, status );

} else if ( strcmp( gsdName, "RXW" ) == 0 ) {

/* RXWC or RXWD depending on frequency
This logic is also found in gsdac_getRecepNames */

if ( gsdVars->centreFreqs[0] < 600.0 ) {
one_strlcpy( instrume, "RXWC", instrumelen, status );
} else {
one_strlcpy( instrume, "RXWD", instrumelen, status );
}


} else if ( strcmp( gsdName, "RXA" ) == 0 ||
strcmp( gsdName, "RXA2" ) == 0 ||
strcmp( gsdName, "RXB2" ) == 0 ||
strcmp( gsdName, "RXC" ) == 0 ||
strcmp( gsdName, "RXC2" ) == 0 ||
strcmp( gsdName, "RXG" ) == 0 ) {

/* These do not need to be changed */
one_strlcpy( instrume, gsdName, instrumelen, status );

} else {

/* Unrecognized frontend */
if ( *status == SAI__OK ) {
*status = SAI__ERROR;
errRepf( "", "Unexpected Frontend of '%s' which will not translate",
status, gsdName );
}
}

return;
}
18 changes: 13 additions & 5 deletions applications/smurf/libgsd/gsdac_putFits.c
Expand Up @@ -143,6 +143,9 @@
* Add additional continuum-recipe objects.
* 2013 June 7 (MJC):
* Add focus recipe.
* 2013-07-28 (TIMJ):
* Use frontend translation routine to get real instrument name.
* Do not assume that "RXB" always has 2 receptors.
* Copyright:
* Copyright (C) 2008-2013 Science and Technology Facilities Council.
Expand Down Expand Up @@ -353,12 +356,17 @@ void gsdac_putFits ( const gsdVars *gsdVars, const int subBandNum,

/* FE Specific. */

/* Truncate the name of the frontend. */
cnfImprt ( gsdVars->frontend, 16, instrume );
/* We need to take the opportunity to correct the frontend name.
In many cases, especially in B-band, the instrument names are
incorrect. */
gsdac_getRealInstrumentName( gsdVars, instrume, sizeof(instrume), status );

/* Get the number of mixers, 2 for RXB & RXW, 1 for others. */
if ( strncmp ( "RXB", gsdVars->frontend, 3 ) == 0 ||
strncmp ( "RXW", gsdVars->frontend, 3 ) == 0 ) {
/* Get the number of mixers, 2 for RXB3 & RXW, 1 for others.
but note that RXB3I has 1. We know that instrume is nul-terminated.
Both RXWC and RXWD have two mixers so just check first 3 characters.
*/
if ( strcmp ( "RXB3", instrume ) == 0 ||
strncmp ( "RXW", instrume, 3 ) == 0 ) {
nMix = 2;
} else {
nMix = 1;
Expand Down

0 comments on commit 25c1b74

Please sign in to comment.