Skip to content

Commit

Permalink
Adding update_obs_grid.
Browse files Browse the repository at this point in the history
  • Loading branch information
dwfncar committed Jul 14, 2024
1 parent 8e6ab48 commit 8bb739f
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 17 deletions.
10 changes: 7 additions & 3 deletions examples/process_swath_data/process_modis_l2.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,12 @@
for time_interval in an.time_intervals:

print(time_interval)

an.open_obs(time_interval=time_interval)

# for obs in an.obs:
# print(an.obs[obs].obj)
print(time_interval)
an.update_obs_grid()

for obs in an.obs:
for obs_time in an.obs[obs].obj:
print('obs_time:', obs_time)
print(an.obs[obs].obj[obs_time])
40 changes: 26 additions & 14 deletions melodies_monet/driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -654,8 +654,8 @@ def __init__(self):
self.model_regridders = None
self.obs_grid = None
self.obs_edges = None
self.obs_gridded_data = None
self.obs_gridded_count = None
self.obs_gridded_data = {}
self.obs_gridded_count = {}

def __repr__(self):
return (
Expand Down Expand Up @@ -977,22 +977,34 @@ def setup_obs_grid(self):
self.control_dict['obs_grid']['end_time'],
ntime, nlat, nlon)

for obs in self.control_dict['obs']:
for var in self.control_dict['obs'][obs]['variables']:
print('initializing gridded data and counts ', obs, var)
self.obs_gridded_data[obs + '_' + var] = np.zeros([ntime, nlon, nlat], dtype=np.float32)
self.obs_gridded_count[obs + '_' + var] = np.zeros([ntime, nlon, nlat], dtype=np.int32)

def update_obs_grid(self):
from .util import grid_util
"""
time_edges (np.array): grid time edges
x_edges (np.array): grid x coord edges
y_edges (np.array): grid y coord edges
time_obs (np.array): obs times
x_obs (np.array): obs x coords
y_obs (np.array): obs y coords
data_obs (np.array): obs data values
count_grid (np.array): number of obs points in grid cell
data_grid (np.array): sum of data values in grid cell
update_data_grid args
time_edges (np.array): grid time edges
x_edges (np.array): grid x coord edges
y_edges (np.array): grid y coord edges
time_obs (np.array): obs times
x_obs (np.array): obs x coords
y_obs (np.array): obs y coords
data_obs (np.array): obs data values
count_grid (np.array): number of obs points in grid cell
data_grid (np.array): sum of data values in grid cell
"""
for obs in self.control_dict['obs']:
for var in self.control_dict['obs'][obs]['variables']:
print('initializing gridded data and counts ', obs, var)
self.obs_gridded_data = np.zeros([ntime, nlon, nlat], dtype=np.float32)
self.obs_gridded_count = np.zeros([ntime, nlon, nlat], dtype=np.int32)
print('updating gridded data and counts ', obs, var)
"""
self.obs_gridded_data[obs + '_' + var]
self.obs_gridded_count[obs + '_' + var]
grid_util.update_data_grid
"""

def pair_data(self, time_interval=None):
"""Pair all observations and models in the analysis class
Expand Down

0 comments on commit 8bb739f

Please sign in to comment.