Timespan is not taken into account in a granule

Following the notebooks from https://docs.google.com/presentation/d/1...913eda_0_0 (specifically about lagrangian advection), a Timespan option doesn't seem to be accounted for. That is, when a granule is loaded to the notebook it is always done regardless of the exact time span I have chosen in the SEAScope viewer.  

These "default" time spans are the following (I know about sea current collections only, as this kind of data is used in the notebook):

-- GlobCurrent geostrophic (current speed): time span is equal to 1 day.
-- Oscar (current speed): time span is equal to 5 days
-- AVISO altimetry (Current from MDT): this granule records the whole span of the collection, i.e. from 2000 to 2020.

I looked up these dates by typing extractions[data]['meta']['start'] and extractions[data]['meta']['stop'] in the notebook. In fact, it is only the metadata which change - the actual dataset (granule) doesn't seem to comprise any different time moments from the one chosen on the timeline in the viewer (without a time span; time span is considered around some date, so a current filed on this exact date is loaded only). Since there are no any other fields for different time moments in a granule, I can't calculate advection or, at least, can't follow the notebook escaping significant changes in code.

Is there the time span bug, or might I forget to do some obvious routine?

And also I would like to copy a cell's content of lagrangian_advection.ipynb 

k_u = [3, 2, 7, 4, 0, 6, 5, 1] # /!\ Change this

# If you have only selected current you can compute k_u automatically
# Uncomment the following lines
# list_name = []
# list_date = []
# for k, data in enumerate(extractions.keys()):
#     list_name.append(os.path.basename(data))
#     list_date.append(extractions[data]['meta']['start'])
# k_u = sorted(range(len(list_date)), key=list_date.__getitem__)


To tell the truth, I did get the point of how to construct this k_u list myself. Should I just create it in a manner of [i for i in range(amount of time moments)] or how?

With my time span bug print(k_u) produces [0] with the commented lines above being uncommented, and "IndexError : list index out of rangeis raised on a line where the advcection is calculated in the cell below (the same notebook), which is understandable, because there is no time evolution of a current field in a granule.

### Set name_var_u, name_var_v
name_var_u = 'eastward_geostrophic_current_velocity' # /!\ Change this
name_var_v = 'northward_geostrophic_current_velocity' # /!\ Change this
#name_var_u = 'u_geo' # /!\ Change this
#name_var_v = 'v_geo' # /!\ Change this
# Get and concatenate velocity variable
u_vel = []
v_vel = []
for ind in k_u:
    granule_uri =  next( v for i, v in enumerate(extractions.keys()) if i == ind )
    extraction = extractions[granule_uri] 

from SEAScope.lib.utils import get_lonlat
lon2D, lat2D = get_lonlat(extraction, numpy.shape(u_vel[0]))

# Advect particles
traj_lon, traj_lat, adv_time = tools_advection.advection(part_lon,
                                part_lat, lon2D, lat2D, u_vel,
                                v_vel, tadv, time_step)
stop_dt = start + datetime.timedelta(days=adv_time[-1])

# Trajectory time
traj_time = []
start_ref = datetime.datetime(2015,12,1)
for i in range(len(adv_time)):
    traj_dt = (start + datetime.timedelta(days=adv_time[i]) - start_ref)

OS is Ubuntu 18.04
Version of Python is 3.6.8

Thank you in advance.

Messages In This Thread
Timespan is not taken into account in a granule - by Pasha Pivaev - 2019-07-07T09:26 PM

Forum Jump: