diff --git a/examples/NWA/NWA_drift.jl b/examples/NWA/NWA_drift.jl new file mode 100644 index 0000000..89d5966 --- /dev/null +++ b/examples/NWA/NWA_drift.jl @@ -0,0 +1,31 @@ + +begin + using Drifters + + s=size(G.DXC[1]) + u=MeshArray(fill(1.0,s))*G.DXC + v=MeshArray(fill(0.5,s))*G.DYC + + u=u/G.DXC; u[findall(isnan.(u))].=0; + v=v/G.DYC; v[findall(isnan.(v))].=0; +# (u,v)=exchange(u,v,1) + if !isdefined(Main,:func) + func=(u -> MeshArrays.update_location_dpdo!(u,Γ)) + end + + F=FlowFields(u,u,v,v,(0.,10.),func) + + x=s[1]*(0.4 .+ 0.2*rand(100)) + y=s[2]*(0.4 .+ 0.2*rand(100)) + I=Individuals(F,x,y,ones(size(x))) + + solve!(I) + + p=1:100; + scatter(I.🔴.x[p],I.🔴.y[p],color=:blue) + p=101:200; + scatter!(I.🔴.x[p],I.🔴.y[p],color=:red) + + current_figure() +end + diff --git a/examples/NWA/NWA_viz.jl b/examples/NWA/NWA_viz.jl new file mode 100644 index 0000000..4968a17 --- /dev/null +++ b/examples/NWA/NWA_viz.jl @@ -0,0 +1,57 @@ + + +using NCDatasets, GLMakie, MeshArrays + +file="ocean_daily.static.nc" +ds=Dataset(file) + +#list below is draft (needs to be double checked; this is just a first guess) +variable_pairs=( +(:Coriolis, :Coriolis), +(:areacello, :RAC), +(:areacello_bu, :RAZ), +(:areacello_cu, :RAW), +(:areacello_cv, :RAS), +(:deptho, :Depth), +(:dxCu, :DXW), +(:dxCv, :DXS), +(:dxt, :DXC), +(:dyCu, :DYW), +(:dyCv, :DYS), +(:dyt, :DYC), +(:geolat, :YC), +(:geolat_c, :YC), +(:geolat_u, :YW), +(:geolat_v, :YS), +(:geolon, :XC), +(:geolon_c, :XC), +(:geolon_u, :XW), +(:geolon_v, :XS), +(:sftof, :SeaAreaFraction), +(:wet, :hFacC), +(:wet_c, :hFacC), +(:wet_u, :hFacW), +(:wet_v, :hFacS), +(:xh, :XC1d), +(:xq, :XZ1d), +(:yh, :YC1d), +(:yq, :XZ1d), +) + +preproc(x) = [(ismissing(i) ? NaN : i) for i in x] + +G=NamedTuple[] +for i in variable_pairs + (n_in,n_out)=i + tmp=try + MeshArray(preproc(ds[n_in][:,:])) + catch +# println("skip $(n_in)") + ds[n_in][:] + end + push!(G,NamedTuple{(n_out,)}((tmp,))) +end + +G=merge(G...) +heatmap(G.Depth) +