Exemplo n.º 1
0
def mass_stat(args):
    files = os.listdir(args.im_folder)
    with open(args.data_file_name, 'a') as data_file:
        for filename in files:
            if filename.startswith(args.stem) and (filename.endswith(".fit") or filename.endswith(".fits")):
                im_path = args.im_folder + filename
                image = fits.open(im_path)
                date = image[0].header['DATE-OBS']
                dt = sidereal.parseDatetime(date)
                st = SidTime(sidereal.SiderealTime.fromDatetime(dt).lst(-2.05393104))
                data_file.write(date + '     ' + str(st) +  imutil.imstat(im_path, Stdout=1)[1] + '\n')
Exemplo n.º 2
0
    amplifiers = 6
    exposure = fits[0].header['EXPTIME']
 elif instrument.count('SALTICAM') > 0:
    amplifiers = 4
    exposure = fits[0].header['EXPTIME']
 else:
    amplifiers = 1
    exposure = fits[0].header['KCT']
    instrument = 'SHOC'
 if i == 0:
    start = (fits[0].header['FRAME']).split('T')[1]
 if i == len(fitslist)-1:
    frames = (fits[0].header['NUMKIN'])
 if ext in ('0',''):
    extensions = 1
    imagestatistics = imutil.imstat(images = fitslist[i]+'[0]'+'[]', mode = "h", fields = 'image,mean',Stdout=1)
    image = imagestatistics[1].split()[0]
    mean = imagestatistics[1].split()[-1]
    print 'Image:', image, 'Mean: ', mean
    means.append(float(mean))
    exposures.append(float(exposure))
    utc = imutil.hselect(images = fitslist[i]+'[0]', fields = '$I,UTC-OBS', expr = 'yes',Stdout=1)[0]
    print >> pulsetiming, image, mean
    print >> pulsetiming, utc
 else:
    ext = int(ext)
    extensions = int(fits[0].header['NEXTEND'])
    print >> pulsetiming, '#  Extentions per cube: ', extensions
    for j in range(extensions/amplifiers):
       imagestatistics = imutil.imstat(images = fitslist[i]+'['+str(j*amplifiers+ext)+']'+'[]', mode = "h", fields = 'image,mean',Stdout=1)
       image = imagestatistics[1].split()[0]
Exemplo n.º 3
0
      # TRANSFORM science files
     #Alexei wiki: transform input=stdstar.fits output=stdstarw.fits fitnames=refspec interptype=linear flux=yes blank=INDEF x1=INDEF x2=INDEF dx=INDEF y1=INDEF y2=INDEF dy=INDEF
      print >> reduction, "longslit.transform(input='spectra"+str(targetcount+1)+".fits', output='f.spectra"+str(targetcount+1)+".fits', fitnames='cr.Arc1', interptype='linear')"
      # TRIM science files to appropriate portion only (relevant line and surrounds)
      print >> reduction, "imutil.imcopy(input='f.spectra"+str(targetcount+1)+".fits[*,"+trimbox+"]', output='tf.spectra"+str(targetcount+1)+".fits', verbose='yes')"
      print >> targetlist, 'Reduced/spectra'+str(targetcount+1)+'.fits'
      #print >> targetlist, '# Original filename:', filenames[i], utcdate, utctime
      #print >> targetlist, '#', gratingvalues
      targetcount = targetcount + 1
      targetfiles.append(filenames[i])
   # FLAT file:			CCDTYPE = 'FLAT              '
   if obstype.count('FLAT') > 0:
      # Strip multi header:
      flatfield = 'Reduced/flat'+str(flatcount+1)+'.fits'
      imutil.imcopy(input=filenames[i]+'[SCI,inherit]', output=flatfield,verbose='yes')
      averageflux = imutil.imstat(images=flatfield, mode="h", fields='image,mean,stddev',Stdout=1)[1].split()[-2]
      imutil.imarith(operand1=flatfield, op="/", operand2=str(averageflux), result=flatfield, title="Normalized FLAT", mode="h")
      print filenames[i]+' is a FLAT'
      print >> flatlist, flatfield
      #print >> flatlist, '# Original filename:', filenames[i], gratingvalues
      flatcount = flatcount + 1

if flatcount > 0:
   # Make MASTER flat
   flatlist.close()
   immatch.imcombine.input = '@flatlist'
   immatch.imcombine.output = 'MasterFlat.fits'                               
   immatch.imcombine.combine = "median"
   immatch.imcombine.reject = "none"
   immatch.imcombine.mode = "h"
   immatch.imcombine()
Exemplo n.º 4
0
 print "#                  (x1,y2)_________________(x2,y2)                        #"
 print "#                        |                 |                              #"
 print "#                  (x1,y1)_________________(x2,y1)                        #"
 print "#                                                                         #"
 print "#  It will help you to determine the standard deviation of the background #"
 print "#  which are required inputs for the IRAF tasks 'daofind' and 'phot'      #"
 print "###########################################################################"
 if dumpdata in ('N','n'):
    os.system("ds9 "+fitslist[0]+"&")
 skybox = raw_input("Enter coordinates of a box without stars in the format [x1:x2,y1:y2] : ") 
 if skybox != '':  
    while skybox.count('[')<1 or skybox.count(']')<1 or skybox.count(':')<2 or skybox.count(',')<1:
       skybox = raw_input("The correct format is [x1:x2,y1:y2] , with all the brackets and punctuation included. Please try again: ")
 print >> inputs, skybox
 # Determine the standard deviation in the backgound
 stddev = imutil.imstat(images = fitslist[0]+skybox , mode = "h", fields = 'image,mean,stddev',Stdout=1)[1].split()[-1]
 print 'STDDEV in the background is :', stddev
 
 # Allow the user to accept the values of the parameter file, revert to default or exit to adjust the file before runnning PHOTscript
 print "###########################################################################"
 print "CONTENTS OF THE 'parameters' FILE IN THIS DIRECTORY IS:"
 print "###########################################################################"
 print "   "
 os.system('cat parameters')
 print "###########################################################################"
 print "   "
 promtpar = raw_input("Do you wish to continue with the photometry using the parameters listed above (Y/N)? ")
 promtpar = checkYNinput(promtpar)
 print >> inputs, promtpar
 if promtpar not in ('Y','y',''):
    print "###########################################################################"
Exemplo n.º 5
0
            1) + ".fits[*," + trimbox + "]', output='tf.spectra" + str(
                targetcount + 1) + ".fits', verbose='yes')"
        print >> targetlist, 'Reduced/spectra' + str(targetcount + 1) + '.fits'
        #print >> targetlist, '# Original filename:', filenames[i], utcdate, utctime
        #print >> targetlist, '#', gratingvalues
        targetcount = targetcount + 1
        targetfiles.append(filenames[i])
    # FLAT file:			CCDTYPE = 'FLAT              '
    if obstype.count('FLAT') > 0:
        # Strip multi header:
        flatfield = 'Reduced/flat' + str(flatcount + 1) + '.fits'
        imutil.imcopy(input=filenames[i] + '[SCI,inherit]',
                      output=flatfield,
                      verbose='yes')
        averageflux = imutil.imstat(images=flatfield,
                                    mode="h",
                                    fields='image,mean,stddev',
                                    Stdout=1)[1].split()[-2]
        imutil.imarith(operand1=flatfield,
                       op="/",
                       operand2=str(averageflux),
                       result=flatfield,
                       title="Normalized FLAT",
                       mode="h")
        print filenames[i] + ' is a FLAT'
        print >> flatlist, flatfield
        #print >> flatlist, '# Original filename:', filenames[i], gratingvalues
        flatcount = flatcount + 1

if flatcount > 0:
    # Make MASTER flat
    flatlist.close()
Exemplo n.º 6
0
        print "#  which are required inputs for the IRAF tasks 'daofind' and 'phot'      #"
        print "###########################################################################"

        skybox = raw_input(
            "Enter coordinates of a box without stars in the format [x1:x2,y1:y2] : "
        )
        if skybox != '':
            while skybox.count('[') < 1 or skybox.count(
                    ']') < 1 or skybox.count(':') < 2 or skybox.count(',') < 1:
                skybox = raw_input(
                    "The correct format is [x1:x2,y1:y2] , with all the brackets and punctuation included. Please try again: "
                )
        print >> inputs, skybox
        # Determine the standard deviation in the backgound
        stddev = imutil.imstat(images=fitslist[0] + skybox,
                               mode="h",
                               fields='image,mean,stddev',
                               Stdout=1)[1].split()[-1]
        print 'STDDEV in the background is :', stddev

    # Allow the user to accept the values of the parameter file, revert to default or exit to adjust the file before runnning PHOTscript
    print "###########################################################################"
    print "CONTENTS OF THE 'parameters' FILE IN THIS DIRECTORY IS:"
    print "###########################################################################"
    print "   "
    os.system('cat parameters')
    print "###########################################################################"
    print "   "
    promtpar = raw_input(
        "Do you wish to continue with the photometry using the parameters listed above (Y/N)? "
    )
    promtpar = checkYNinput(promtpar)