Spaces:
Sleeping
Sleeping
update the file format for further extension
Browse files
app.py
CHANGED
|
@@ -20,64 +20,6 @@ import param
|
|
| 20 |
|
| 21 |
pn.extension("tabulator")
|
| 22 |
|
| 23 |
-
def greg_0h(jourjul):
|
| 24 |
-
import math
|
| 25 |
-
# Julian days start and end at noon.
|
| 26 |
-
# Julian day 2440000 begins at 00 hours, May 23, 1968.
|
| 27 |
-
|
| 28 |
-
# Round the input Julian day number to avoid precision errors
|
| 29 |
-
fac = 10**9
|
| 30 |
-
jourjul = np.round(fac * jourjul + 0.5) / fac
|
| 31 |
-
|
| 32 |
-
# Calculate seconds in the day
|
| 33 |
-
secs = (jourjul % 1) * 24 * 3600
|
| 34 |
-
|
| 35 |
-
# Round seconds to avoid precision errors
|
| 36 |
-
secs = np.round(fac * secs + 0.5) / fac
|
| 37 |
-
|
| 38 |
-
# Gregorian calendar conversion
|
| 39 |
-
j = math.floor(jourjul) - 1721119
|
| 40 |
-
in_ = 4 * j - 1
|
| 41 |
-
y = math.floor(in_ / 146097)
|
| 42 |
-
j = in_ - 146097 * y
|
| 43 |
-
in_ = math.floor(j / 4)
|
| 44 |
-
in_ = 4 * in_ + 3
|
| 45 |
-
j = math.floor(in_ / 1461)
|
| 46 |
-
d = math.floor(((in_ - 1461 * j) + 4) / 4)
|
| 47 |
-
in_ = 5 * d - 3
|
| 48 |
-
m = math.floor(in_ / 153)
|
| 49 |
-
d = math.floor(((in_ - 153 * m) + 5) / 5)
|
| 50 |
-
y = y * 100 + j
|
| 51 |
-
if m < 10:
|
| 52 |
-
mo = m + 3
|
| 53 |
-
yr = y
|
| 54 |
-
else:
|
| 55 |
-
mo = m - 9
|
| 56 |
-
yr = y + 1
|
| 57 |
-
|
| 58 |
-
hour = math.floor(secs / 3600)
|
| 59 |
-
mins = math.floor((secs % 3600) / 60)
|
| 60 |
-
sec = int(secs % 60)
|
| 61 |
-
|
| 62 |
-
gtime = [yr, mo, d, hour, mins, sec]
|
| 63 |
-
|
| 64 |
-
return gtime
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
def fix_time(ds):
|
| 68 |
-
from datetime import datetime, timedelta
|
| 69 |
-
|
| 70 |
-
time = ds["TIME"]
|
| 71 |
-
time2 = time.dropna(dim="MAXT")
|
| 72 |
-
time2 = time2.reindex_like(time, method="nearest")
|
| 73 |
-
jourjul = [greg_0h(jourjul) for jourjul in time2.values]
|
| 74 |
-
date = [
|
| 75 |
-
datetime(jourjul[0], jourjul[1], jourjul[2], jourjul[3], jourjul[4], jourjul[5])
|
| 76 |
-
for jourjul in jourjul
|
| 77 |
-
]
|
| 78 |
-
date = xr.DataArray(date, dims="MAXT")
|
| 79 |
-
return ds.assign(TIME=date)
|
| 80 |
-
|
| 81 |
@pn.cache(max_items=32,policy='LRU',per_session=True)
|
| 82 |
def load_csv():
|
| 83 |
df = pd.read_csv('./data/zarr_table.csv',index_col=None)
|
|
@@ -139,8 +81,8 @@ def quiver_depth_filterd(ax,ds_filtered, depth1, depth_range_slider, scale_facto
|
|
| 139 |
lat = ds_filtered.coords["LATITUDE"].values
|
| 140 |
|
| 141 |
# Moyenne des vecteurs de courant sur la plage de profondeur sélectionnée
|
| 142 |
-
u_mean = depth_filtered.UCUR.mean(dim="
|
| 143 |
-
v_mean = depth_filtered.VCUR.mean(dim="
|
| 144 |
|
| 145 |
return ax.quiver(
|
| 146 |
lon,
|
|
@@ -317,15 +259,15 @@ class SADCP_Viewer(param.Parameterized):
|
|
| 317 |
figsize=(8, 7), subplot_kw={"projection": ccrs.Mercator()}
|
| 318 |
)
|
| 319 |
coords = ["LATITUDE", "LONGITUDE"]
|
| 320 |
-
corsen = max(1, self.ds_filtered.
|
| 321 |
self.ds_filtered = (
|
| 322 |
self.ds_filtered.reset_coords(coords)
|
| 323 |
-
.coarsen({"
|
| 324 |
.mean()
|
| 325 |
.set_coords(coords)
|
| 326 |
)
|
| 327 |
|
| 328 |
-
# self.ds_filtered =self.ds_filtered.coarsen(
|
| 329 |
|
| 330 |
quiver_depth_filterd(ax,self.ds_filtered, self.depth1, self.depth_range_slider,self.scale_factor_slider,color="blue")
|
| 331 |
|
|
@@ -370,10 +312,10 @@ class SADCP_Viewer(param.Parameterized):
|
|
| 370 |
def hvplot_plots(self):
|
| 371 |
import hvplot.xarray
|
| 372 |
return [
|
| 373 |
-
self.ds_filtered["BATHY"].max(dim="
|
| 374 |
-
self.ds_filtered["USHIP"].max(dim="
|
| 375 |
-
self.ds_filtered["VSHIP"].max(dim="
|
| 376 |
-
self.ds_filtered["BOTTOM_DEPTH"].max(dim="
|
| 377 |
|
| 378 |
]
|
| 379 |
|
|
|
|
| 20 |
|
| 21 |
pn.extension("tabulator")
|
| 22 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 23 |
@pn.cache(max_items=32,policy='LRU',per_session=True)
|
| 24 |
def load_csv():
|
| 25 |
df = pd.read_csv('./data/zarr_table.csv',index_col=None)
|
|
|
|
| 81 |
lat = ds_filtered.coords["LATITUDE"].values
|
| 82 |
|
| 83 |
# Moyenne des vecteurs de courant sur la plage de profondeur sélectionnée
|
| 84 |
+
u_mean = depth_filtered.UCUR.mean(dim="PROFZ", skipna=True)
|
| 85 |
+
v_mean = depth_filtered.VCUR.mean(dim="PROFZ", skipna=True)
|
| 86 |
|
| 87 |
return ax.quiver(
|
| 88 |
lon,
|
|
|
|
| 259 |
figsize=(8, 7), subplot_kw={"projection": ccrs.Mercator()}
|
| 260 |
)
|
| 261 |
coords = ["LATITUDE", "LONGITUDE"]
|
| 262 |
+
corsen = max(1, self.ds_filtered.TIME.size // self.num_vectors_slider.value)
|
| 263 |
self.ds_filtered = (
|
| 264 |
self.ds_filtered.reset_coords(coords)
|
| 265 |
+
.coarsen({"TIME": corsen}, boundary="trim")
|
| 266 |
.mean()
|
| 267 |
.set_coords(coords)
|
| 268 |
)
|
| 269 |
|
| 270 |
+
# self.ds_filtered =self.ds_filtered.coarsen(TIME = corsen, side = "center", boundary = "trim").mean()[["LONGITUDE", "LONGITUDE", "TIME"]].isel(PROFZ=0)
|
| 271 |
|
| 272 |
quiver_depth_filterd(ax,self.ds_filtered, self.depth1, self.depth_range_slider,self.scale_factor_slider,color="blue")
|
| 273 |
|
|
|
|
| 312 |
def hvplot_plots(self):
|
| 313 |
import hvplot.xarray
|
| 314 |
return [
|
| 315 |
+
self.ds_filtered["BATHY"].max(dim="PROFZ").hvplot(x="TIME", width=400, height=200),
|
| 316 |
+
self.ds_filtered["USHIP"].max(dim="PROFZ").hvplot(x="TIME", width=400, height=200),
|
| 317 |
+
self.ds_filtered["VSHIP"].max(dim="PROFZ").hvplot(x="TIME", width=400, height=200),
|
| 318 |
+
self.ds_filtered["BOTTOM_DEPTH"].max(dim="PROFZ").hvplot(x="TIME", width=400, height=200),
|
| 319 |
|
| 320 |
]
|
| 321 |
|