Exemplo n.º 1
0
def run_calcqu(input_data,config,harmonic):
    #  The following call to SMURF:CALCQU creates two HDS container files -
    #  one holding a set of Q NDFs and the other holding a set of U NDFs. Create
    #  these container files in the NDG temporary directory.
    qcont = NDG(1)
    qcont.comment = "qcont"
    ucont = NDG(1)
    ucont.comment = "ucont"

    msg_out( "Calculating Q and U values for each bolometer...")
    invoke("$SMURF_DIR/calcqu in={0} config=\"{1}\" lsqfit=no outq={2} outu={3} "
           "harmonic={4} fix".format(input_data,starutil.shell_quote(config),
                                     qcont,ucont,harmonic) )
    return (qcont,ucont)
Exemplo n.º 2
0
def run_calcqu(input_data, config, harmonic):
    #  The following call to SMURF:CALCQU creates two HDS container files -
    #  one holding a set of Q NDFs and the other holding a set of U NDFs. Create
    #  these container files in the NDG temporary directory.
    qcont = NDG(1)
    qcont.comment = "qcont"
    ucont = NDG(1)
    ucont.comment = "ucont"

    msg_out("Calculating Q and U values for each bolometer...")
    invoke(
        "$SMURF_DIR/calcqu in={0} config=\"{1}\" lsqfit=no outq={2} outu={3} "
        "harmonic={4} fix".format(input_data, starutil.shell_quote(config),
                                  qcont, ucont, harmonic))
    return (qcont, ucont)
Exemplo n.º 3
0
      if instrument0 == None:
         if instrument != None:
            parsys["INSTRUMENT"].default = instrument
            parsys["INSTRUMENT"].noprompt = True
         instrument = parsys["INSTRUMENT"].value
         instrument0 = instrument

      elif instrument != None:
         if instrument0 != instrument:
            raise starutil.InvalidParameterError("Tile {0} is for instrument "
                     "{1} - others are for {2}.".format(tile,instrument,instrument0) )
      else:
         instrument = instrument0;

   instrument = starutil.shell_quote( instrument )

#  Assume the Region is not an NDF.
   region_is_ndf = False
   lz = None
   uz = None

#  If no region was supplied, get the centre and radius of a circular
#  area on the sky, and create an AST Region from them.
   cen1 = None
   cen2 = None
   if region == None :
      system = parsys["SYSTEM"].value
      if system == "ICRS" :
         parsys["CENTRE1"].prompt = "RA at centre of required circle"
         parsys["CENTRE2"].prompt = "Dec at centre of required circle"
Exemplo n.º 4
0
   elif waveband1 != waveband2:
      msg_out( "\n  Supplied NDFs are for different wavebands", starutil.CRITICAL )

#  Tell the user what wavebands are being used.
   if waveband1 == waveband2:
      msg_out( "\n  Showing {0} um values".format(waveband1),
            starutil.CRITICAL)
   else:
      msg_out( "\n  Showing {0} um values from {1}".format(waveband1,config1),
               starutil.CRITICAL)
      msg_out( "\n  Showing {0} um values from {1}".format(waveband2,config2),
               starutil.CRITICAL)

#  Get the waveband selection specifier for config1.
   if waveband1 == "450":
      select = starutil.shell_quote( '"850=0,450=1"' )
   else:
      select = starutil.shell_quote( '"850=1,450=0"' )

#  Deal with cases where we are comparing two whole configs...
   if param == None:

#  List the configuration parameters in alphabetical order to a text file.
      if isndf1:
         conf1 = invoke("$KAPPA_DIR/configecho ndf={0} application=makemap "
                        "config=! name=! sort=yes defaults={1} select={2}".
                        format(config1,defs,select) )
      else:
         config1 = starutil.shell_quote( config1 )
         conf1 = invoke("$KAPPA_DIR/configecho ndf=! application=makemap "
                        "config={0} name=! sort=yes defaults={1} select={2}".
Exemplo n.º 5
0
   elif waveband1 != waveband2:
      msg_out( "\n  Supplied NDFs are for different wavebands", starutil.CRITICAL )

#  Tell the user what wavebands are being used.
   if waveband1 == waveband2:
      msg_out( "\n  Showing {0} um values".format(waveband1),
            starutil.CRITICAL)
   else:
      msg_out( "\n  Showing {0} um values from {1}".format(waveband1,config1),
               starutil.CRITICAL)
      msg_out( "\n  Showing {0} um values from {1}".format(waveband2,config2),
               starutil.CRITICAL)

#  Get the waveband selection specifier for config1.
   if waveband1 == "450":
      select = starutil.shell_quote( '"850=0,450=1"' )
   else:
      select = starutil.shell_quote( '"850=1,450=0"' )

#  Deal with cases where we are comparing two whole configs...
   if param is None:

#  List the configuration parameters in alphabetical order to a text file.
      if isndf1:
         conf1 = invoke("$KAPPA_DIR/configecho ndf={0} application=makemap "
                        "config=! name=! sort=yes defaults={1} select={2}".
                        format(config1,defs,select) )
      else:
         config1 = starutil.shell_quote( config1 )
         conf1 = invoke("$KAPPA_DIR/configecho ndf=! application=makemap "
                        "config={0} name=! sort=yes defaults={1} select={2}".
Exemplo n.º 6
0
#  Get the output catalogue now to avoid a long wait before the user gets
#  prompted for it.
   outcat = parsys["CAT"].value

#  Get the alignment domain.
   domain = parsys["DOMAIN"].value

#  Get the pixel size to use. If no pixel size is supplied we use the pixel
#  size of the total intensity map if supplied, or of the Q and U maps
#  created by SMURF:CALCQU otherwise.
   pixsize = parsys["PIXSIZE"].value
   ref = None

#  Get the cleaning config, and quote it so that any shell metacharacters are
#  passed unchanged to the SMURF:CALCQU task.
   config = starutil.shell_quote( parsys["CONFIG"].value )

#  Get the graphics device for graphical output. Normalisation plots will
#  only be produced if at least one of ILEVEL and GLEVEL is DEBUG.
   device = parsys["DEVICE"].value
   if device != None:
      device = starutil.shell_quote( device )
      if starutil.ilevel >= starutil.DEBUG or starutil.glevel >= starutil.DEBUG:
         ndevice = device
      else:
         ndevice = "!"
   else:
      device = "!"
      ndevice = "!"

#  Get the quantity to use as the vector lengths (could be "None")
Exemplo n.º 7
0
            elif cval == "DAS":
                deflt = "DAS"

            else:
                deflt = None

    except:
        deflt = None

    if deflt is not None:
        parsys["INSTRUMENT"].default = deflt
        parsys["INSTRUMENT"].noprompt = True

#  Get the JCMT instrument. Quote the string so that it can be used as
#  a command line argument when running an atask from the shell.
    instrument = starutil.shell_quote(parsys["INSTRUMENT"].value)
    msg_out("Updating tiles for {0} data".format(instrument))

    #  See if temp files are to be retained.
    retain = parsys["RETAIN"].value

    #  Set up the dynamic default for parameter "JSA". This is True if the
    #  dump of the WCS FrameSet in the first supplied NDF contains the string
    #  "HPX".
    prj = invoke(
        "$KAPPA_DIR/wcsattrib ndf={0} mode=get name=projection".format(
            indata[0]))
    parsys["JSA"].default = True if prj.strip() == "HEALPix" else False

    #  See if input NDFs are on the JSA all-sky pixel grid.
    jsa = parsys["JSA"].value
Exemplo n.º 8
0
                                    "DAS"],
                                    "The JCMT instrument", "SCUBA-2(850)"))

   params.append(starutil.Par0L("RETAIN", "Retain temporary files?", False,
                                 noprompt=True))

#  Initialise the parameters to hold any values supplied on the command
#  line.
   parsys = ParSys( params )

#  It's a good idea to get parameter values early if possible, in case
#  the user goes off for a coffee whilst the script is running and does not
#  see a later parameter propmpt or error...
   region = parsys["REGION"].value
   outdata = parsys["OUT"].value
   instrument = starutil.shell_quote( parsys["INSTRUMENT"].value )
   retain = parsys["RETAIN"].value

#  Report what we will be doing...
   msg_out( "Creating a cut-out for {0} data".format(instrument) )

   tiledir = os.getenv( 'JSA_TILE_DIR' )
   if tiledir:
      msg_out( "Tiles will be read from {0}".format(tiledir) )
   else:
      msg_out( "Environment variable JSA_TILE_DIR is not set!" )
      msg_out( "Tiles will be read from the current directory ({0})".format(os.getcwd()) )

#  Create an empty list to hold the NDFs for the tiles holding the
#  required data.
   tilendf = []
Exemplo n.º 9
0
         if cval == "ACSIS":
            instrument = "ACSIS"

         elif cval == "DAS":
            instrument = "DAS"

#  If so, set the default for the INSTRUMENT parameter and prevent the
#  user being prompted for a value.
      if instrument != None:
         parsys["INSTRUMENT"].default = instrument
         parsys["INSTRUMENT"].noprompt = True

#  Get the chosen instrument.
      instrument = parsys["INSTRUMENT"].value
      instrument = starutil.shell_quote( instrument )

#  Get a list of the tiles that overlap the Region.
      invoke( "$SMURF_DIR/jsatilelist in={0} instrument={1} quiet".format(region,instrument) )
      tiles = starutil.get_task_par( "TILES", "jsatilelist" )

#  List them.
      for tile in tiles:
         msg_out( "Tile {0} touches {1}".format(tile, indata))

#  Remove temporary files.
   cleanup()

#  If an StarUtilError of any kind occurred, display the message but hide the
#  python traceback. To see the trace back, uncomment "raise" instead.
except starutil.StarUtilError as err:
Exemplo n.º 10
0
    params.append(
        starutil.Par0L("RETAIN",
                       "Retain temporary files?",
                       False,
                       noprompt=True))

    #  Initialise the parameters to hold any values supplied on the command
    #  line.
    parsys = ParSys(params)

    #  It's a good idea to get parameter values early if possible, in case
    #  the user goes off for a coffee whilst the script is running and does not
    #  see a later parameter propmpt or error...
    region = parsys["REGION"].value
    outdata = parsys["OUT"].value
    instrument = starutil.shell_quote(parsys["INSTRUMENT"].value)
    retain = parsys["RETAIN"].value

    #  Report what we will be doing...
    msg_out("Creating a cut-out for {0} data".format(instrument))

    tiledir = os.getenv('JSA_TILE_DIR')
    if tiledir:
        msg_out("Tiles will be read from {0}".format(tiledir))
    else:
        msg_out("Environment variable JSA_TILE_DIR is not set!")
        msg_out("Tiles will be read from the current directory ({0})".format(
            os.getcwd()))

#  Create an empty list to hold the NDFs for the tiles holding the
#  required data.
Exemplo n.º 11
0
            if instrument is not None:
                parsys["INSTRUMENT"].default = instrument
                parsys["INSTRUMENT"].noprompt = True
            instrument = parsys["INSTRUMENT"].value
            instrument0 = instrument

        elif instrument is not None:
            if instrument0 != instrument:
                raise starutil.InvalidParameterError(
                    "Tile {0} is for instrument "
                    "{1} - others are for {2}.".format(tile, instrument,
                                                       instrument0))
        else:
            instrument = instrument0

    instrument = starutil.shell_quote(instrument)

    #  Assume the Region is not an NDF.
    region_is_ndf = False
    lz = None
    uz = None

    #  If no region was supplied, get the centre and radius of a circular
    #  area on the sky, and create an AST Region from them.
    cen1 = None
    cen2 = None
    if region is None:
        system = parsys["SYSTEM"].value
        if system == "ICRS":
            parsys["CENTRE1"].prompt = "RA at centre of required circle"
            parsys["CENTRE2"].prompt = "Dec at centre of required circle"
Exemplo n.º 12
0
        if cval == "ACSIS":
            instrument = "ACSIS"

        elif cval == "DAS":
            instrument = "DAS"

#  If so, set the default for the INSTRUMENT parameter and prevent the
#  user being prompted for a value.
    if instrument is not None:
        parsys["INSTRUMENT"].default = instrument
        parsys["INSTRUMENT"].noprompt = True

#  Get the chosen instrument.
    instrument = parsys["INSTRUMENT"].value
    instrument = starutil.shell_quote(instrument)

    #  Get a list of the tiles that overlap the supplied NDF.
    invoke("$SMURF_DIR/jsatilelist in={0} instrument={1} quiet".format(
        inndf, instrument))
    tiles = starutil.get_task_par("TILES", "jsatilelist")

    #  JSADICER requires the input array to be gridded on the JSA all-sky
    #  pixel grid. This is normally an HPX projection, but if the supplied
    #  NDF straddles a discontinuity in the HPX projection then we need to
    #  use a different flavour of HPX (either an HPX projection centred on
    #  RA=12h or am XPH (polar HEALPix) projection centred on the north or
    #  south pole). The above call to jsatileinfo will have determined the
    #  appropriate projection to use, so get it.
    proj = starutil.get_task_par("PROJ", "jsatilelist")
Exemplo n.º 13
0
            if cval == "ACSIS":
                instrument = "ACSIS"

            elif cval == "DAS":
                instrument = "DAS"

#  If so, set the default for the INSTRUMENT parameter and prevent the
#  user being prompted for a value.
        if instrument is not None:
            parsys["INSTRUMENT"].default = instrument
            parsys["INSTRUMENT"].noprompt = True

#  Get the chosen instrument.
        instrument = parsys["INSTRUMENT"].value
        instrument = starutil.shell_quote(instrument)

        #  Get a list of the tiles that overlap the Region.
        invoke("$SMURF_DIR/jsatilelist in={0} instrument={1} quiet".format(
            region, instrument))
        tiles = starutil.get_task_par("TILES", "jsatilelist")

        #  List them.
        for tile in tiles:
            msg_out("Tile {0} touches {1}".format(tile, indata))

#  Remove temporary files.
    cleanup()

#  If an StarUtilError of any kind occurred, display the message but hide the
#  python traceback. To see the trace back, uncomment "raise" instead.
Exemplo n.º 14
0
         elif cval == "DAS":
            deflt = "DAS"

         else:
            deflt = None

   except:
      deflt = None

   if deflt != None:
      parsys["INSTRUMENT"].default = deflt
      parsys["INSTRUMENT"].noprompt = True

#  Get the JCMT instrument. Quote the string so that it can be used as
#  a command line argument when running an atask from the shell.
   instrument = starutil.shell_quote( parsys["INSTRUMENT"].value )
   msg_out( "Updating tiles for {0} data".format(instrument) )

#  See if temp files are to be retained.
   retain = parsys["RETAIN"].value

#  Set up the dynamic default for parameter "JSA". This is True if the
#  dump of the WCS FrameSet in the first supplied NDF contains the string
#  "HPX".
   prj = invoke("$KAPPA_DIR/wcsattrib ndf={0} mode=get name=projection".format(indata[0]) )
   parsys["JSA"].default = True if prj.strip() == "HEALPix" else False

#  See if input NDFs are on the JSA all-sky pixel grid.
   jsa = parsys["JSA"].value
   if not jsa:
      msg_out( "The supplied NDFs will first be resampled onto the JSA "
Exemplo n.º 15
0
   elif waveband1 != waveband2:
      msg_out( "\n  Supplied NDFs are for different wavebands", starutil.CRITICAL )

#  Tell the user what wavebands are being used.
   if waveband1 == waveband2:
      msg_out( "\n  Showing {0} um values".format(waveband1),
            starutil.CRITICAL)
   else:
      msg_out( "\n  Showing {0} um values from {1}".format(waveband1,config1),
               starutil.CRITICAL)
      msg_out( "\n  Showing {0} um values from {1}".format(waveband2,config2),
               starutil.CRITICAL)

#  Get the waveband selection specifier for config1.
   if waveband1 == "450":
      select = starutil.shell_quote( "'850=0,450=1'" )
   else:
      select = starutil.shell_quote( "'850=1,450=0'" )

#  Deal with cases where we are comparing two whole configs...
   if param == None:

#  List the configuration parameters in alphabetical order to a text file.
      if isndf1:
         conf1 = invoke("$KAPPA_DIR/configecho ndf={0} application=makemap "
                        "config=! name=! sort=yes defaults={1} select={2}".
                        format(config1,defs,select) )
      else:
         config1 = starutil.shell_quote( config1 )
         conf1 = invoke("$KAPPA_DIR/configecho ndf=! application=makemap "
                        "config={0} name=! sort=yes defaults={1} select={2}".