<commit_before>from read_spec import *
from read_spec import Inst
# Instrument parameters

inst = __name__[5:]   # HARPS, HARPSpre, HARPSpost, HARPN
name = inst[:5]       # HARPS, HARPN  (passed to bary)
obsname = {'HARPS': 'eso', 'HARPN': 'lapalma'}[name] # for barycorrpy
iomax = {'HARPS': 72, 'HARPN': 69}[name]
oset = {'HARPS': '10:71', 'HARPN': '10:'}[name]

pat = "*.tar *e2ds_%(fib)s.fits *e2ds_%(fib)s.fits.gz *_S2D_%(fib)s.fits"   # space separated suffices
#maskfile = 'telluric_mask_carm_short.dat'

def scan(self, s, pfits=True, verb=False):
   """
   SYNTAX: read_harps(filename)
   OUTPUT: namedtuple('spectrum', 'w f berv bjd blaze drift timeid sn55 ')
           w    - wavelength
           f    - flux
           berv - Barycentric Earth Radial Velocity
           bjd  - Barycentric Julian Day
           blaze - Blaze filename
           drift - Used RV Drift
           sn55  - S_N order center55

   """
   drs = self.drs
   if '.tar' in s:
      s = file_from_tar(s, inst=inst, fib=self.fib, pfits=pfits)

   if isinstance(s, str) and '.gz' in s:
      # if s is isinstance(s,tarfile.ExFileObject) then s.position will change !? resulting in:
      # *** IOError: Empty or corrupt FITS file<commit_msg>chore: Barycentric correction with astropy for HARPS.<commit_after>from read_spec import *
from read_spec import Inst
# Instrument parameters

inst = __name__[5:]   # HARPS, HARPSpre, HARPSpost, HARPN
name = inst[:5]       # HARPS, HARPN  (passed to bary)
obsname = {'HARPS': 'eso', 'HARPN': 'lapalma'}[name]   # for barycorrpy     # obsname = 'lasilla'
obsloc = {'HARPS': dict(lat=-29.2584, lon=-70.7345, elevation=2400.),       # from brv_we14.py,  for astropy bary
          'HARPN': dict(lat=28.754000, lon=-17.88905555, elevation=2387.2)}[name]
iomax = {'HARPS': 72, 'HARPN': 69}[name]
oset = {'HARPS': '10:71', 'HARPN': '10:'}[name]

pat = "*.tar *e2ds_%(fib)s.fits *e2ds_%(fib)s.fits.gz *_S2D_%(fib)s.fits"   # space separated suffices
#maskfile = 'telluric_mask_carm_short.dat'

def scan(self, s, pfits=True, verb=False):
   """
   SYNTAX: read_harps(filename)
   OUTPUT: namedtuple('spectrum', 'w f berv bjd blaze drift timeid sn55 ')
           w    - wavelength
           f    - flux
           berv - Barycentric Earth Radial Velocity
           bjd  - Barycentric Julian Day
           blaze - Blaze filename
           drift - Used RV Drift
           sn55  - S_N order center55

   """
   drs = self.drs
   if '.tar' in s:
      s = file_from_tar(s, inst=inst, fib=self.fib, pfits=pfits)

   if isinstance(s, str) and '.gz' in s:
      # if s is isinstance(s,tarfile.ExFileObject) then s.position will change !? resulting in:
      # *** IOError: Empty or corrupt FITS file
{'fraction_non_alphanumeric': 0.13706705969049374, 'fraction_numerical': 0.030582166543846722, 'mean_word_length': 2.9751098096632504, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '1602124', 'n_tokens_mistral': 1104, 'n_tokens_neox': 985, 'n_words': 269}