Here we (1) retrieve SCOPE-Gradients cruise data from the Simons' CMAP data base and (2) collocate with mean dymanic topography / SSH.
Pre-requisites:
pip
PyCmap
<30s
)pycmap
(via pycall
), Plots
, and helper functions
You may need to replace your-own-API-key
(as outline below) with your own API key from Simons' CMAP and uncomment the command below.
if false
run(`pip install pycmap`) #pycmap is used via PyCall later
run(pipeline(`which python`,"whichpython.txt")) #external python path
ENV["PYTHON"]=readline("whichpython.txt")
import Pkg; Pkg.build("PyCall")
end
using PyCall
PyCmap = pyimport("pycmap")
#cmap = PyCmap.API(token="your-own-API-key")
cmap = PyCmap.API()
using Plots
include("helper_functions.jl")
┌ Info: Precompiling MeshArrays [cb8c808f-1acf-59a3-9d2b-6e38d009f683] └ @ Base loading.jl:1273 ┌ Info: Precompiling MITgcmTools [62725fbc-3a66-4df3-9000-e33e85b3a198] └ @ Base loading.jl:1273
Main.cbiomes_helpers
Downloading the catalog is a simple way to verify that cmap is all set-up. The commented df.to_csv
command writes the content of df
to a new catalog.csv
file. Alternatively, Pandas.jl
can be used as also shown.
df = cmap.get_catalog();
#df.to_csv("catalog.csv")
#df=Pandas.DataFrame(cmap.get_catalog());
#to_csv(df,"catalog.csv")
.csv
Files)¶A simple method is to download data from CMAP
and store it to a CSV
file which any software can then reload. Below, cmap_helpers.tables
provide CMAP table
lists for SCOPE-Gradients cruise data, which cmap.get_dataset
downloads one at a time. Alternatively one can use the computer's memory (later slides).
pth="../samples/gradients/"
!isdir("$pth") ? mkdir("$pth") : nothing
Γ=1:3
γ=filter(x -> occursin("tblKM1906",x), readdir(pth))
!isempty(γ) ? Γ = [] : nothing
for g in Γ
list0=cmap_helpers.tables("G$g")
for i in list0
df=cmap.get_dataset(i)
df.to_csv("$pth$i.csv")
end
end
As an example below we read, and then plot, the LISST
data collected during the Gradients 3
cruise.
s=cmap_helpers.get("tblKM1906_Gradients3_uway_optics","LISST_small")
m=cmap_helpers.get("tblKM1906_Gradients3_uway_optics","LISST_medium")
l=cmap_helpers.get("tblKM1906_Gradients3_uway_optics","LISST_large")
Dict{String,Any} with 8 entries: "Long_Name" => "LISST C 20-100.0 micron" "Unit" => "umol C/L" "lat" => [21.2464, 21.2464, 21.2464, 21.2464, 21.2465, 21.2465, 21.24… "time" => ["2019-04-10T00:39:37", "2019-04-10T00:42:07", "2019-04-10T0… "Variable" => "LISST_large" "val" => [NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN … NaN, N… "lon" => [-158.034, -158.037, -158.041, -158.045, -158.048, -158.052,… "Data_Source" => "Prof. Dr. Angelicque A. White, University of Hawaii, aewhit…
Here we interpolate a sea surface height
climatology estimate (Forget et al 2015) along the ship track. Any number of commonly available methods can readily be used to interpolate gridded estimates to observed locations. For MITgcm
output in our example, we use MeshArrays.jl
method.
ssh=cbiomes_helpers.myinterp(pth,"SSH",s["lon"],s["lat"])
ssh=merge(ssh,Dict("Unit" => "m", "Variable" => "SSH", "Long_Name" => "Sea Surface Height (Mean Dynamic Topography)"))
Dict{String,Any} with 7 entries: "lat" => [21.2464, 21.2464, 21.2464, 21.2464, 21.2465, 21.2465, 21.24… "Long_Name" => "Sea Surface Height (Mean Dynamic Topography)" "Unit" => "m" "Variable" => "SSH" "val" => [0.701766, 0.701738, 0.70171, 0.70168, 0.70165, 0.701618, 0.… "lon" => [-158.034, -158.037, -158.041, -158.045, -158.048, -158.052,… "Data_Source" => "ECCOv4r2 (Gael Forget)"
LISST data collected in Gradients 3 and the sea surface height climatology.
t=1:10:length(s["lat"])
scatter(s["lat"][t],s["val"][t],marker = 1.5,label=s["Long_Name"],
xlabel="°N",ylabel=s["Unit"], title="Gradients 3 (subset)")
scatter!(m["lat"][t],m["val"][t],marker = 1.5,label=m["Long_Name"])
scatter!(l["lat"][t],l["val"][t],marker = 1.5,label=l["Long_Name"])
plot!(ssh["lat"][t],(1.0.-ssh["val"][t]).*5.0,linecolor=:black,label="(1.- ssh in m) * 5")
Gradients1
, Gradients2
, and Gradients3
are plotted one after the other. Note the strong covariations, in each case, with the ship moving back and forth across the gyre in each case.
s1=cmap_helpers.get("tblKOK1606_Gradients1_uway_optics","LISST_small")
m1=cmap_helpers.get("tblKOK1606_Gradients1_uway_optics","LISST_medium")
l1=cmap_helpers.get("tblKOK1606_Gradients1_uway_optics","LISST_large")
ssh1=cbiomes_helpers.myinterp(pth,"SSH",s1["lon"],s1["lat"])
t=1:5:length(s1["lat"])
scatter(s1["val"][t],marker = 2,label=s["Long_Name"],
ylabel=s["Unit"], title="Gradients 1 (subset)")
scatter!(m1["val"][t],marker = 2,label=m["Long_Name"])
scatter!(l1["val"][t],marker = 2,label=l["Long_Name"])
plot!((1.0.-ssh1["val"][t]).*20.0,linecolor=:black,label="(1.- ssh in m) * 20")
plot!(s1["lat"][t]./10.,linecolor=:black,linestyle = :dash,label="°N / 10")
s2=cmap_helpers.get("tblMGL1704_Gradients2_uway_optics","LISST_small")
m2=cmap_helpers.get("tblMGL1704_Gradients2_uway_optics","LISST_medium")
l2=cmap_helpers.get("tblMGL1704_Gradients2_uway_optics","LISST_large")
ssh2=cbiomes_helpers.myinterp(pth,"SSH",s2["lon"],s2["lat"])
t=1:5:length(s2["lat"])
scatter(s2["val"][t],marker = 2,label=s["Long_Name"],
ylabel=s["Unit"], title="Gradients 2 (subset)")
scatter!(m2["val"][t],marker = 2,label=m["Long_Name"])
scatter!(l2["val"][t],marker = 2,label=l["Long_Name"])
plot!((1.0.-ssh2["val"][t]).*5.0,linecolor=:black,label="(1.- ssh in m) * 5")
plot!(s2["lat"][t]./10.0,linecolor=:black,linestyle = :dash,label="°N / 10")
t=1:10:length(s["lat"])
plot(s["val"][t],marker = 2,label=s["Long_Name"],
ylabel=s["Unit"], title="Gradients 3 (subset)")
plot!(m["val"][t],marker = 2,label=m["Long_Name"])
plot!(l["val"][t],marker = 2,label=l["Long_Name"])
plot!((1.0.-ssh["val"][t]).*5.0,linecolor=:black,label="(1.- ssh in m) * 5")
plot!(s["lat"][t]./10.0,linecolor=:black,linestyle = :dash,label="(lat in °N) / 5")