Skip to content

Instantly share code, notes, and snippets.

View ShihengDuan's full-sized avatar
☘️
Focusing

ShihengATM ShihengDuan

☘️
Focusing
View GitHub Profile
@ShihengDuan
ShihengDuan / process_prism.py
Created September 24, 2023 01:15
Process '.bil' RPISM data to netcdf files.
import xcdat as xc
import xarray as xa
import glob
import zipfile
from osgeo import gdal
import numpy as np
import argparse
import os
def get_args():
@ShihengDuan
ShihengDuan / calculation_metrics.py
Last active September 14, 2023 03:32
Calculate KGE, NSE for 3-D xarray data (time, lat, Lon)
def calculate_kge(obs_data, model_data):
mean_obs = obs_data.mean(dim='time')
mean_model = model_data.mean(dim='time')
obs_std = obs_data.std(dim='time')
model_std = model_data.std(dim='time')
upper = (model_data-mean_model)*(obs_data-mean_obs)
upper = upper.sum(dim='time')
lower_x = np.square(model_data-mean_model)