Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
# [Unreleased] - yyyy-mm-dd

### Fixed
- update hsrl.py to use py3 integer divide. fixes date parsing.

### Added
- add optional explicit bin ordering to aop.py yaml. this allows for calculating AOP's for a single bin, or subset of bins

Expand Down
28 changes: 14 additions & 14 deletions src/pyobs/hsrl.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"""

import h5py
from numpy import ones, zeros, interp, NaN, isnan, array
import numpy as np
from datetime import datetime, timedelta

from .config import strTemplate
Expand Down Expand Up @@ -86,7 +86,7 @@
# -----------
Short_Name = dict(
gps_alt = 'lev',
gps_date = 'datex',
gps_date = 'date',
gps_lat = 'lat',
gps_lon = 'lon',
gps_time = 'time',
Expand Down Expand Up @@ -171,11 +171,11 @@ def __init__ (self,hsrl_filename,Nav_only=False,verbose=True,freq=3.0,
# -----------------------------------------------
if self.nt != self.date.shape[0]:
date_ = self.date[0,0]
yy = int(date_)/10000
mm = (int(date_) - yy * 10000)/100
yy = int(date_)//10000
mm = (int(date_) - yy * 10000)//100
dd = int(date_) - yy*10000 - mm*100
dates = '%02d/%02d/%4d'%(mm,dd,yy)
self.date = array([dates for i in range(self.nt)])
self.date = np.array([dates for i in range(self.nt)])

# Create datetime
# ---------------
Expand All @@ -184,7 +184,7 @@ def __init__ (self,hsrl_filename,Nav_only=False,verbose=True,freq=3.0,
dt = timedelta(seconds = int(self.time[i]* 60. * 60.+0.5))
mm, dd, yy = self.date[i].split('/')
self.Time += [datetime(int(yy), int(mm), int(dd)) + dt,]
self.Time = array(self.Time)
self.Time = np.array(self.Time)
self.tyme = self.Time.reshape((self.nt,1))

# Find bracketing synoptic times
Expand All @@ -204,7 +204,7 @@ def __init__ (self,hsrl_filename,Nav_only=False,verbose=True,freq=3.0,
# ------------------------------------------
self.IA = [] # index and weight for time interpolation
for t in self.syn[:-1]:
a = ones(self.nt)
a = np.ones(self.nt)
I = (a==1.)
for n in range(self.nt):
I[n] = (self.Time[n]>=t)&(self.Time[n]<t+self.dt_syn)
Expand Down Expand Up @@ -293,9 +293,9 @@ def zInterp(self,v5):
if self.H.shape[1] != nz:
raise ValueError('inconsistent GEOS-5 vertical dimension')

v = ones((self.nt,self.nz)) # same size as HSRL arrays
v = np.ones((self.nt,self.nz)) # same size as HSRL arrays
for t in range(self.nt):
v[t,:] = interp(self.z,self.H[t,:],v5[t,:],left=NaN)
v[t,:] = np.interp(self.z,self.H[t,:],v5[t,:],left=np.nan)

return v

Expand Down Expand Up @@ -326,14 +326,14 @@ def curtain(self,v, tit=None, vmin=None, vmax=None,figFile=None,
v_ = v[:,:]

if mask_as != None:
mask = isnan(mask_as[:,:])
mask = np.isnan(mask_as[:,:])
if mask != None:
v_[mask] = NaN
v_[mask] = np.nan

if vmin is not None:
v_[v_<vmin] = NaN
v_[v_<vmin] = np.nan
if vmax is not None:
v_[v_>vmax] = NaN
v_[v_>vmax] = np.nan

gca().set_axis_bgcolor('black')

Expand Down Expand Up @@ -432,7 +432,7 @@ def _attachVarXYT (self,g5_filename,Vars):
# Interpolate in each synoptic interval
# -------------------------------------
s = 0
v = NaN * zeros(V[0].shape)
v = np.nan * np.zeros(V[0].shape)
for I, a in self.IA:
a_ = a[I]
if len(v.shape) == 1:
Expand Down
Loading