Page MenuHomec4science

interpolate_unc.py
No OneTemporary

File Metadata

Created
Wed, May 14, 21:13

interpolate_unc.py

import numpy as np
import pandas as pd
import xarray as xr
from pvlib.solarposition import get_solarposition
import util
import os
import time
import sys
### USER INPUT
FILEPATH = sys.argv[1] # file path (WITHOUT EXTENSION!)
# Load uncertainty
fp = '%s.nc' %FILEPATH
phys_pot = xr.open_mfdataset(fp, chunks = {'x':200, 'y':200})
# Step 1: change timestamp
phys_pot_corrected = phys_pot.copy()
phys_pot_corrected.coords['hour'] = phys_pot_corrected.hour + 0.5
# Step 2: interpolate corrected data to old timestamps
phys_pot_interp = phys_pot_corrected.interp(hour = phys_pot.hour)
# Step 3: save results
fp = '%s_interp.nc' %FILEPATH
print('Interpolated results; now saving to file %s' %fp)
phys_pot_interp.to_netcdf(fp)

Event Timeline