<commit_before>import scipy
import sys,os
try:
   from astropy.io import fits as pyfits
except:
   import pyfits

if len(sys.argv)>1:
   files = sys.argv[1:]
else:
   dir = os.curdir
   files = os.listdir(dir)

print \
    "#   File          nx x ny         Object       t_exp    Instrument Filter  "
print \
    "#--------------  ---------  ----------------- --------- ---------- --------"

for f in files:

   # Open the fits file
   try:
      hdulist = pyfits.open(f)
   except:
      try:
         hdulist = pyfits.open(f,ignore_missing_end=True)
      except:
         print "Unable to open file %s" % f
         continue

   if f[-5:] == ".fits":
      fname = f[:-5]
   elif f[-4:] == ".FIT":
      fname = f[:-4]
   else:
      fname = f

   # Get information that is likely to be in the PHDU
   # Perhaps most important is the instrument
   hdr = hdulist[0].header

   # Instrument
   try:
      inst = hdr['instrume'].strip()
   except:
      try:
         inst = hdr['currinst'].strip()
      except:
         inst = None

   # Set some default values for instrument-specific parameters
   usecoadd  = False
   inst2     = None
   objname   = 'object'
   texpname  = 'exptime'
   texpname2 = 'exptime'
   filtname  = 'filter'
   coaddname = 'coadds'

   # Set instrument-specific parameter value
   if inst is not None:
      if inst == 'NICMOS':
         objname = 'targname'
         inst2   = 'aperture'
      elif inst == 'NIRI':
         usecoadd  = True
         texpname  = 'coaddexp'
         filtname  = 'filter1'
      elif inst == 'NIRC2':
         usecoadd = True
         texpname = 'itime'
      elif inst == 'NIRSPEC':
         usecoadd = True
         texpname = 'itime'
         filtname = 'filname'
      elif inst[0:4] == 'LRIS':
         inst = 'LRIS'
         texpname = 'ttime'
         filtname = 'redfilt'
      elif inst[0:3] == 'ESI':
         inst = 'ESI'
         texpname = 'ttime'
         filtname = 'dwfilnam'
      elif inst == 'WFPC2':
         objname = 'targname'
         filtname = 'filtnam1'
      elif inst == 'MOIRCS':
         filtname = 'filter01'
      elif inst == 'SuprimeCam':
         filtname = 'filter01'

   # Get object name
   try:
      obj = hdr[objname].strip()
   except:
      obj = '(No_object)'

   # Get data size
   if len(hdulist) > 1:
      hext = 1
   else:
      hext = 0
   try:
      n1 = hdulist[hext].header['naxis1']
   except:
      n1 = 0
   try:
      n2 = hdulist[hext].header['naxis2']<commit_msg>Updated imhead.py to include more instruments<commit_after>import scipy
import sys,os
try:
   from astropy.io import fits as pyfits
except:
   import pyfits

if len(sys.argv)>1:
   files = sys.argv[1:]
else:
   dir = os.curdir
   files = os.listdir(dir)

print \
    "#   File          nx x ny         Object       t_exp    Instrument Filter  "
print \
    "#--------------  ---------  ----------------- --------- ---------- --------"

for f in files:

   # Open the fits file
   try:
      hdulist = pyfits.open(f)
   except:
      try:
         hdulist = pyfits.open(f,ignore_missing_end=True)
      except:
         print "Unable to open file %s" % f
         continue

   if f[-5:] == ".fits":
      fname = f[:-5]
   elif f[-4:] == ".FIT":
      fname = f[:-4]
   else:
      fname = f

   # Get information that is likely to be in the PHDU
   # Perhaps most important is the instrument
   hdr = hdulist[0].header

   # Instrument
   try:
      inst = hdr['instrume'].strip()
   except:
      try:
         inst = hdr['currinst'].strip()
      except:
         inst = None

   # Set some default values for instrument-specific parameters
   usecoadd  = False
   inst2     = None
   objname   = 'object'
   texpname  = 'exptime'
   texpname2 = 'exptime'
   filtname  = 'filter'
   coaddname = 'coadds'

   # Set instrument-specific parameter value
   if inst is not None:

      """ HST Instruments """
      if inst == 'ACS':
         objname = 'targname'
         filtname = 'filter2'
      if inst == 'NICMOS':
         objname = 'targname'
         inst2   = 'aperture'
      elif inst == 'WFC3':
         objname = 'targname'
      elif inst == 'WFPC2':
         objname = 'targname'
         filtname = 'filtnam1'

      ### Keck Instruments ###
      elif inst[0:3] == 'ESI':
         inst = 'ESI'
         texpname = 'ttime'
         filtname = 'dwfilnam'
      elif inst[0:4] == 'LRIS':
         inst = 'LRIS'
         texpname = 'ttime'
         filtname = 'redfilt'
      elif inst == 'NIRC2':
         usecoadd = True
         texpname = 'itime'
      elif inst == 'NIRSPEC':
         usecoadd = True
         texpname = 'itime'
         filtname = 'filname'

      ### Subaru Instruments ###
      elif inst == 'MOIRCS':
         filtname = 'filter01'
      elif inst == 'SuprimeCam':
         filtname = 'filter01'

      ### Other Instruments ###
      elif inst == 'NIRI':
         usecoadd  = True
         texpname  = 'coaddexp'
         filtname  = 'filter1'

   # Get object name
   try:
      obj = hdr[objname].strip()
   except:
      obj = '(No_object)'

   # Get data size
   if len(hdulist) > 1:
      hext = 1
   else:
      hext = 0
   try:
      n1 = hdulist[hext].header['naxis1']
   except:
      n1 = 0
   try:
      n2 = hdulist[hext].header['naxis2']
{'fraction_non_alphanumeric': 0.14033756874644415, 'fraction_numerical': 0.01213730324293571, 'mean_word_length': 1.659606656580938, 'pattern_counts': {'":': 4, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '758182', 'n_tokens_mistral': 1881, 'n_tokens_neox': 1820, 'n_words': 474}