Skip to content
Snippets Groups Projects
Commit a013a17a authored by tomrink's avatar tomrink
Browse files

snapshot...

parent b571b497
No related branches found
No related tags found
No related merge requests found
......@@ -2,19 +2,12 @@ import glob
import tensorflow as tf
import util.util
from util.setup import logdir, modeldir, cachepath, now, ancillary_path
from util.util import EarlyStop, normalize, denormalize, resample, resample_2d_linear, resample_one,\
resample_2d_linear_one, get_grid_values_all, add_noise, smooth_2d, smooth_2d_single, median_filter_2d,\
median_filter_2d_single, downscale_2x
from util.setup import logdir, modeldir, now, ancillary_path
from util.util import EarlyStop, normalize, get_grid_values_all
import os, datetime
import numpy as np
import pickle
import h5py
from scipy.ndimage import gaussian_filter
# L1B M/I-bands: /apollo/cloud/scratch/cwhite/VIIRS_HRES/2019/2019_01_01/
# CLAVRx: /apollo/cloud/scratch/Satellite_Output/VIIRS_HRES/2019/2019_01_01/
# /apollo/cloud/scratch/Satellite_Output/andi/NEW/VIIRS_HRES/2019
LOG_DEVICE_PLACEMENT = False
......@@ -326,7 +319,6 @@ class SRCNN:
tmp = tmp.copy()
lo, hi, std, avg = get_min_max_std(tmp)
# std = np.where(np.isnan(std), 0, std)
lo = normalize(lo, param, mean_std_dct)
hi = normalize(hi, param, mean_std_dct)
avg = normalize(avg, param, mean_std_dct)
......@@ -334,7 +326,6 @@ class SRCNN:
data_norm.append(lo[:, slc_y, slc_x])
data_norm.append(hi[:, slc_y, slc_x])
data_norm.append(avg[:, slc_y, slc_x])
# data_norm.append(std[:, slc_y, slc_x])
# ---------------------------------------------------
tmp = input_data[:, label_idx, :, :]
tmp = tmp.copy()
......@@ -776,36 +767,37 @@ def run_evaluate_static(in_file, out_file, ckpt_dir):
h5f = h5py.File(in_file, 'r')
grd_a = get_grid_values_all(h5f, 'orig/temp_11_0um')
grd_a = np.where(np.isnan(grd_a), 0, grd_a)
grd_a = normalize(grd_a, 'temp_11_0um_nom', mean_std_dct)
grd_b = get_grid_values_all(h5f, 'super/refl_0_65um')
grd_b = np.where(np.isnan(grd_b), 0, grd_b)
grd_b = np.expand_dims(grd_b, axis=0)
lo, hi, std, avg = get_min_max_std(grd_b)
lo = normalize(lo, 'refl_0_65um_nom', mean_std_dct)
hi = normalize(hi, 'refl_0_65um_nom', mean_std_dct)
avg = normalize(avg, 'refl_0_65um_nom', mean_std_dct)
lo = np.squeeze(lo)
hi = np.squeeze(hi)
avg = np.squeeze(avg)
grd_c = get_grid_values_all(h5f, 'orig/'+label_param)
grd_c = np.where(np.isnan(grd_c), 0, grd_c)
data = np.stack([grd_a, lo, hi, avg, grd_c], axis=2)
bt = get_grid_values_all(h5f, 'orig/temp_11_0um')
bt = np.where(np.isnan(bt), 0, bt)
bt = normalize(bt, 'temp_11_0um_nom', mean_std_dct)
refl = get_grid_values_all(h5f, 'super/refl_0_65um')
refl = np.where(np.isnan(refl), 0, refl)
refl = np.expand_dims(refl, axis=0)
refl_lo, refl_hi, refl_std, refl_avg = get_min_max_std(refl)
refl_lo = normalize(refl_lo, 'refl_0_65um_nom', mean_std_dct)
refl_hi = normalize(refl_hi, 'refl_0_65um_nom', mean_std_dct)
refl_avg = normalize(refl_avg, 'refl_0_65um_nom', mean_std_dct)
refl_lo = np.squeeze(refl_lo)
refl_hi = np.squeeze(refl_hi)
refl_avg = np.squeeze(refl_avg)
cp = get_grid_values_all(h5f, 'orig/'+label_param)
cp = np.where(np.isnan(cp), 0, cp)
data = np.stack([bt, refl_lo, refl_hi, refl_avg, cp], axis=2)
data = np.expand_dims(data, axis=0)
h5f.close()
nn = SRCNN()
out_sr = nn.run_evaluate(data, ckpt_dir)
out_sr = out_sr.argmax(axis=3)
probs = nn.run_evaluate(data, ckpt_dir)
cld_frac = probs.argmax(axis=3)
if out_file is not None:
np.save(out_file, (out_sr[0, :, :], grd_a, avg, grd_c))
np.save(out_file, (cld_frac[0, :, :], bt, refl_avg, cp))
else:
return out_sr[0, :, :], grd_a, avg, grd_c
return cld_frac[0, :, :], bt, refl_avg, cp
def analyze2(nda_m, nda_i):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment