Page MenuHomec4science

check_files.py
No OneTemporary

File Metadata

Created
Fri, May 23, 13:30

check_files.py

import xarray as xr
import sys
import os
fileDir = sys.argv[1]
batches = int(sys.argv[2])
WORKDIR = '/scratch/walch/workdir_solar_MMH_base'
FLATDIR = '/scratch/walch/workdir_solar_EW_scenarios'
ROOF_FP = os.path.join(FLATDIR, 'files/flat_roofs_baseline.csv')
AREA_FP = '/work/hyenergy/output/solar_potential/geographic_potential/available_area/PRED_available_area_unc_filled.csv'
for batch in range(batches):
print(batch)
poa_fp = os.path.join(fileDir, 'poa_irradiance_%d.nc' %batch)
irrad_fp = os.path.join(fileDir, 'tilted_irrad_%d.nc' %batch)
pvPot_fp = os.path.join(fileDir, 'pv_potential_%d.nc' %batch)
check_irrad = False
try:
irrad = xr.open_dataset(irrad_fp)
poa = xr.open_dataset(poa_fp)
print(len(irrad.DF_UID))
print(len(poa.DF_UID))
if irrad.yearly_kWh_m2.sum() == 0:
print(len(irrad.DF_UID))
print('ERROR in %s' %irrad_fp)
irrad.close()
poa.close()
os.system('%s/python compute_tilted_irrad_batch.py %s %s %s' %(WORKDIR, poa_fp, ROOF_FP, irrad_fp))
check_irrad = True
except:
print('Cannot open %s or %s' %(poa_fp,irrad_fp))
continue
try:
pvPot = xr.open_dataset(pvPot_fp)
if pvPot.yearly_PV_kWh.sum() > 0:
continue
except:
print('Cannot open %s' %pvPot_fp)
if not check_irrad:
continue
print('ERROR in %s' %pvPot_fp)
pvPot.close()
os.system('python %s/compute_PV_output_batch.py %s %s %s %s' %(WORKDIR, irrad_fp, ROOF_FP, AREA_FP, pvPot_fp))

Event Timeline