Ejemplo n.º 1
0
def make_callist(callist,caldir):
    """make_callist(callist, caldir)

    This reads in the file specified as callist.
    The path must be absolute, or the routine will return False

    The caldir is used to constructed the Frame object, so that future
    functions will know where the actual is located (thus, in theory,
    the calibration file and the callist can be in two different
    places.)

    
    """
    try:
        calfile = open(callist)
    except:
        return(False)

    calfilestr = calfile.read()
    calfilelist = calfilestr.splitlines()

    calframes = []
    flags = ""
    for line in calfilelist:
        linearray = line.split()
        if len(linearray) == 7:
            [filename,camera,filetype,grating,wavelen,xb,yb] = linearray
        elif len(linearray) > 7:
            [filename,camera,filetype,grating,wavelen,xb,yb] = linearray[0:6]
            flags = " ".join(linearray[6:])
        else:
            return([])
        calframe = Frame(name=filename,path=caldir,display_name=filename)
        calframe.grating = grating
        calframe.wavelength = wavelen
        calframe.type = filetype
        calframe.xbinning = xb
        calframe.ybinning = yb
        calframe.flags = flags
        calframe.exptime = 1
        calframe.target = 'horizon lock'
        calframe.aperture = 'long_1.0'

        if camera == "r":
            calframe.instrument=Instrument(name=u'lrisred',display_name=u'LRISRED')
        elif camera == "b":
            calframe.instrument =Instrument(name=u'lrisblue',display_name=u'LRISBLUE')
        
        calframes.append(calframe)
#        make_gratingdir(filename,grating,stddir)

    
    return(calframes)
Ejemplo n.º 2
0
def addframe(frame_name,hdr,obsdate,obstime,filename,path,instrument=""):
    """ addframe(frame_name,hdr,obsdate,obstime,filename,path,instrument)

    frame_name - the unique frame name
    hdr - FITS header
    obsdate- datetime object that is the date  from hdr
    obstime- datetime object that is the time  from hdr
    filename - the filename on the file system, this should be related to the
               frame_name
    path - the relative path to the object, not including what is the datapath

    This builds the actual frame instance.
    frame_name is a unique key for the name of the datafile.  Based on the hdr
    data, the routine fills in the information that the db needs to classify
    the file and run the pipelines with the correct input
    """
    msg = ''
    frame = Frame(frame_name,path,
                  filename,
                  header = hdr,
                  use_mark = True,
                  observeddate = obsdate,
                  observedtime = datetime.combine(obsdate,obstime))
    if instrument == "":
        instrument = find_instrument_name(hdr)

#    print "Instrument = ",instrument
    if instrument == "lrisred" :
#        print "Is a red frame!"
        frame.instrument = Instrument(name=u'lrisred',display_name=u'LRISRED'
                                      )
        frame = LRISFrameutil.addframelris(frame,hdr,instrument)
    elif instrument == "lrisblue":
        frame.instrument = Instrument(name=u'lrisblue',display_name=u'LRISBLUE',
                                      )

        frame = LRISFrameutil.addframelris(frame,hdr,instrument)
    if not frame:
        msg="There is something wrong with %s" % frame_name
        

    return(msg,frame)
Ejemplo n.º 3
0
def makecallist(callist,caldir,stddir):

    try:
        calfile = open(callist)
    except:
        return(False)

    calfilestr = calfile.read()
    calfilelist = calfilestr.splitlines()

    calframes = []
    flags = ""
    for line in calfilelist:
        linearray = line.split()
        if len(linearray) == 7:
            [filename,camera,filetype,grating,wavelen,xb,yb] = linearray
        elif len(linearray) > 7:
            [filename,camera,filetype,grating,wavelen,xb,yb] = linearray[0:6]
            flags = " ".join(linearray[7:])
        else:
            return([])
        calframepath = findframe(caldir,camera,grating,filename)
        if calframepath:
            calframe = Frame(name=filename,path=calframepath,display_name=filename)
            calframe.grating = grating
            calframe.wavelength = float(wavelen)
            calframe.type = filetype
            calframe.xbinning = int(xb)
            calframe.ybinning = int(yb)
            calframe.flags = flags
            if camera == "r":
                calframe.instrument=Instrument(name=u'lrisred',display_name=u'LRISRED')
            elif camera == "b":
                calframe.instrument =Instrument(name=u'lrisblue',display_name=u'LRISBLUE')
            calframes.append(calframe)
            make_gratingdir(filename,grating,stddir)
        else:
            print "Cannot find file %s in %s or appropriate subdirectories." % (filename,caldir)
    
    return(calframes)