Page MenuHomec4science

interpolate_covrr.py
No OneTemporary

File Metadata

Created
Tue, May 13, 02:06

interpolate_covrr.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['timestamp'] = phys_pot_corrected.timestamp + pd.Timedelta(0.5, unit = 'h')
# Step 2: interpolate corrected data to old timestamps
phys_pot_interp = phys_pot_corrected.interp(timestamp = phys_pot.timestamp)
# 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