#!/usr/bin/env python3 ''' Name: rtofs_prep_trim_ndbc_files.py Contact(s): Mallory Row (mallory.row@noaa.gov) Abstract: This trims the NDBC individual buoy text files for only data for a single date Run By: scripts/prep/rtofs/exevs_rtofs_prep.sh ''' import os import pandas as pd import datetime import glob import shutil print("BEGIN: "+os.path.basename(__file__)) # Read in environment variables to use VDATE = os.environ['VDATE'] DATA = os.environ['DATA'] DCOMROOT = os.environ['DCOMROOT'] SENDCOM = os.environ['SENDCOM'] COMOUTprep = os.environ['COMOUTprep'] RUN = os.environ['RUN'] MET_NDBC_STATIONS = os.environ['MET_NDBC_STATIONS'] # Set up dates VDATE_dt = datetime.datetime.strptime(VDATE, '%Y%m%d') # Assign header columns in NDBC individual buoy files ndbc_header1 = ("#YY MM DD hh mm WDIR WSPD GST WVHT DPD APD MWD " +"PRES ATMP WTMP DEWP VIS PTDY TIDE\n") ndbc_header2 = ("#yr mo dy hr mn degT m/s m/s m sec sec degT " +"hPa degC degC degC nmi hPa ft\n") # Read in location data file buoy_with_loc_list = [] for line in open(MET_NDBC_STATIONS, 'r'): buoy_with_loc_list.append( line.partition(' 0: print(f"Copying {ndbc_input_file} to {ndbc_tmp_file}") shutil.copy2(ndbc_input_file, ndbc_tmp_file) else: print("WARNING: {ndbc_input_file} empty, 0 sized") if SENDCOM == 'YES': if os.path.getsize(ndbc_tmp_file) > 0: print(f"Copying {ndbc_tmp_file} to {ndbc_output_file}") shutil.copy2(ndbc_tmp_file, ndbc_output_file) else: print("WARNING: {ndbc_tmp_file} empty, 0 sized")