tinaok commited on
Commit
fec3245
1 Parent(s): de6d2b8
Files changed (1) hide show
  1. app.py +53 -64
app.py CHANGED
@@ -113,7 +113,8 @@ import param
113
  import xarray as xr
114
 
115
  @pn.cache(max_items=32,policy='LRU',per_session=True)
116
- def load_csv(url):
 
117
  fs = fsspec.filesystem("https")
118
  with fs.open(url) as f:
119
  df = pd.read_csv(f,index_col=None)
@@ -121,12 +122,15 @@ def load_csv(url):
121
  return df
122
 
123
  @pn.cache(max_items=4,policy='LRU',per_session=True)
124
- def load_bathymetry(url):
 
125
  fs = fsspec.filesystem("https")
126
  return xr.open_dataset(fs.open(url), decode_times=False, use_cftime=True)
127
 
128
  @pn.cache(max_items=16,policy='LRU',per_session=True)
129
- def load_netCDF(file_path):
 
 
130
  fs = fsspec.filesystem("https")
131
  ds = (
132
  xr.open_dataset(
@@ -137,21 +141,32 @@ def load_netCDF(file_path):
137
  .set_xindex("PROFZ")
138
  .set_xindex("TIME")
139
  )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
140
  return fix_time(ds)
141
 
142
-
143
-
144
-
145
-
146
-
147
-
148
  class SADCP_Viewer(param.Parameterized):
149
- #file_csv = "https://data-eurogoship.ifremer.fr/data/table.csv"
150
- #file = fs.open(file_csv)
151
- df = load_csv("https://data-eurogoship.ifremer.fr/data/table.csv")
152
- bathy = load_bathymetry("https://data-eurogoship.ifremer.fr/bathymetrie/bathy6min.nc")
153
- #df = pd.read_csv(file, index_col=None).sort_values(by="year")
154
- # df = pd.read_csv("table.csv", index_col=None).sort_values(by="year")
155
  file_names = df["file_name"].tolist()
156
  years = sorted(df["year"].unique())
157
 
@@ -250,55 +265,29 @@ class SADCP_Viewer(param.Parameterized):
250
  ]
251
  )
252
 
253
- data_dir = "https://data-eurogoship.ifremer.fr/copy_seadatanet/"
254
- file_path = os.path.join(data_dir, selected_file)
255
- self.ds=load_netCDF(file_path)
256
- #file_path = fs.open(file_path)
257
- #self.ds = (
258
- #xr.open_dataset(
259
- #file_path, decode_cf=True, decode_times=False, engine="scipy"
260
- #)
261
- # .squeeze()
262
- # .set_coords(["LONGITUDE", "LATITUDE", "TIME", "PROFZ"])
263
- #@.set_xindex("PROFZ")
264
- # .set_xindex("TIME")
265
- # )
266
-
267
- self.ds = self.ds.where(
268
- (self.ds.VCUR_SEADATANET_QC == 49)
269
- & (self.ds.UCUR_SEADATANET_QC == 49)
270
- #& (self.ds.WCUR_SEADATANET_QC == 49)
271
- #& (self.ds.ECUR_SEADATANET_QC == 49)
272
- # & (self.ds.PGOOD_SEADATANET_QC == 49)
273
- #& (self.ds.ECI_SEADATANET_QC == 49)
274
- #& (self.ds.BOTTOM_DEPTH_SEADATANET_QC == 49)
275
- # & (self.ds.BATHY_SEADATANET_QC == 49)
276
- & (self.ds.USHIP_SEADATANET_QC == 49)
277
- & (self.ds.VSHIP_SEADATANET_QC == 49),
278
- drop=False)
279
- self.ds = self.ds[
280
- [
281
- "USHIP",
282
- "VSHIP",
283
- "ROLL",
284
- "PITCH",
285
- "TR_TEMP",
286
- "HEADING",
287
- "U_BOTTOM",
288
- "V_BOTTOM",
289
- "UCUR",
290
- "VCUR",
291
- "WCUR",
292
- "ECUR",
293
- "PGOOD",
294
- "ECI",
295
- "BATHY",
296
- "UTIDE",
297
- "VTIDE",
298
- "BOTTOM_DEPTH",
299
- "TIME",
300
- ]
301
- ]
302
 
303
 
304
  lon_range = (
 
113
  import xarray as xr
114
 
115
  @pn.cache(max_items=32,policy='LRU',per_session=True)
116
+ def load_csv():
117
+ url="https://data-eurogoship.ifremer.fr/data/table.csv"
118
  fs = fsspec.filesystem("https")
119
  with fs.open(url) as f:
120
  df = pd.read_csv(f,index_col=None)
 
122
  return df
123
 
124
  @pn.cache(max_items=4,policy='LRU',per_session=True)
125
+ def load_bathymetry():
126
+ url="https://data-eurogoship.ifremer.fr/bathymetrie/bathy6min.nc"
127
  fs = fsspec.filesystem("https")
128
  return xr.open_dataset(fs.open(url), decode_times=False, use_cftime=True)
129
 
130
  @pn.cache(max_items=16,policy='LRU',per_session=True)
131
+ def load_netCDF(selected_file):
132
+ data_dir = "https://data-eurogoship.ifremer.fr/copy_seadatanet/"
133
+ file_path = os.path.join(data_dir, selected_file)
134
  fs = fsspec.filesystem("https")
135
  ds = (
136
  xr.open_dataset(
 
141
  .set_xindex("PROFZ")
142
  .set_xindex("TIME")
143
  )
144
+ ds = ds.where(
145
+ (ds.VCUR_SEADATANET_QC == 49)
146
+ & (ds.UCUR_SEADATANET_QC == 49)
147
+ #& (ds.WCUR_SEADATANET_QC == 49)
148
+ #& (ds.ECUR_SEADATANET_QC == 49)
149
+ # & (ds.PGOOD_SEADATANET_QC == 49)
150
+ #& (ds.ECI_SEADATANET_QC == 49)
151
+ #& (ds.BOTTOM_DEPTH_SEADATANET_QC == 49)
152
+ # & (ds.BATHY_SEADATANET_QC == 49)
153
+ & (ds.USHIP_SEADATANET_QC == 49)
154
+ & (ds.VSHIP_SEADATANET_QC == 49),
155
+ drop=False)
156
+ ds = ds[
157
+ [
158
+ "TIME",
159
+ "USHIP", "VSHIP", "BATHY", "BOTTOM_DEPTH",
160
+ "UCUR", "VCUR",
161
+ # "ROLL", "PITCH", "TR_TEMP", "HEADING", "U_BOTTOM", "V_BOTTOM",
162
+ # "WCUR", "ECUR", "PGOOD", "ECI", "UTIDE", "VTIDE",
163
+ ]
164
+ ]
165
  return fix_time(ds)
166
 
 
 
 
 
 
 
167
  class SADCP_Viewer(param.Parameterized):
168
+ df = load_csv()
169
+ bathy = load_bathymetry()
 
 
 
 
170
  file_names = df["file_name"].tolist()
171
  years = sorted(df["year"].unique())
172
 
 
265
  ]
266
  )
267
 
268
+ self.ds=load_netCDF(selected_file)
269
+
270
+ # self.ds = self.ds.where(
271
+ # (self.ds.VCUR_SEADATANET_QC == 49)
272
+ # & (self.ds.UCUR_SEADATANET_QC == 49)
273
+ # #& (self.ds.WCUR_SEADATANET_QC == 49)
274
+ # #& (self.ds.ECUR_SEADATANET_QC == 49)
275
+ # # & (self.ds.PGOOD_SEADATANET_QC == 49)
276
+ # #& (self.ds.ECI_SEADATANET_QC == 49)
277
+ # #& (self.ds.BOTTOM_DEPTH_SEADATANET_QC == 49)
278
+ # # & (self.ds.BATHY_SEADATANET_QC == 49)
279
+ # & (self.ds.USHIP_SEADATANET_QC == 49)
280
+ # & (self.ds.VSHIP_SEADATANET_QC == 49),
281
+ # drop=False)
282
+ # self.ds = self.ds[
283
+ # [
284
+ # "TIME",
285
+ # "USHIP", "VSHIP", "BATHY", "BOTTOM_DEPTH",
286
+ # "UCUR", "VCUR",
287
+ # "ROLL", "PITCH", "TR_TEMP", "HEADING", "U_BOTTOM", "V_BOTTOM",
288
+ # "WCUR", "ECUR", "PGOOD", "ECI", "UTIDE", "VTIDE",
289
+ # ]
290
+ # ]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
291
 
292
 
293
  lon_range = (