Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem reading data without local_cdi_id and edmo_code #106

Closed
MartinHanssonSMHI opened this issue Sep 16, 2022 · 4 comments
Closed

Problem reading data without local_cdi_id and edmo_code #106

MartinHanssonSMHI opened this issue Sep 16, 2022 · 4 comments

Comments

@MartinHanssonSMHI
Copy link

We have problem reading ODV generated nc-files since the data do not contain local_cdi, edmo_code etc.

datafile2 = "C:/Work/DIVAnd/Test/data/data_from_Seabird_Collection_2022-06-01T13-55-00.nc"
@time obsval2, obslon2, obslat2, obsdepth2, obstime2, obsid2 = NCODV.load(Float64, datafile2, "Temperature");

┌ Warning: No variable with the long_name attribute 'LOCAL_CDI_ID' in C:/Work/DIVAnd/Test/data/data_from_Seabird_Collection_2022-06-01T13-55-00.nc found. We use the empty string for LOCAL_CDI_ID instead.
└ @ DIVAnd.NCODV C:\Users\a001109.julia\packages\DIVAnd\Iwjb1\src\NCODV.jl:327
No NetCDF variable found with attribute 'long_name' equal to 'EDMO_CODE' in C:\Work\DIVAnd\Test\data\data_from_Seabird_Collection_2022-06-01T13-55-00.nc

Stacktrace:
[1] error(s::String)
@ Base .\error.jl:33
[2] varbyattrib_first(ds::NCDataset{Nothing}; kwargs::Base.Iterators.Pairs{Symbol, String, Tuple{Symbol}, NamedTuple{(:long_name,), Tuple{String}}})
@ DIVAnd.NCODV C:\Users\a001109.julia\packages\DIVAnd\Iwjb1\src\NCODV.jl:15
[3] (::DIVAnd.NCODV.var"#10#11"{Int64, DataType, String, String, Vector{String}})(ds::NCDataset{Nothing})
@ DIVAnd.NCODV C:\Users\a001109.julia\packages\DIVAnd\Iwjb1\src\NCODV.jl:348
[4] NCDataset(f::DIVAnd.NCODV.var"#10#11"{Int64, DataType, String, String, Vector{String}}, args::String; kwargs::Base.Iterators.Pairs{Union{}, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
@ NCDatasets C:\Users\a001109.julia\packages\NCDatasets\XVX8L\src\dataset.jl:220
[5] NCDataset(f::Function, args::String)
@ NCDatasets C:\Users\a001109.julia\packages\NCDatasets\XVX8L\src\dataset.jl:218
[6] #load#9
@ C:\Users\a001109.julia\packages\DIVAnd\Iwjb1\src\NCODV.jl:322 [inlined]
[7] load(T::Type, fname::String, long_name::String)
@ DIVAnd.NCODV C:\Users\a001109.julia\packages\DIVAnd\Iwjb1\src\NCODV.jl:320
[8] top-level scope
@ .\timing.jl:210 [inlined]
[9] top-level scope
@ .\In[11]:0
[10] eval
@ .\boot.jl:360 [inlined]
[11] include_string(mapexpr::typeof(REPL.softscope), mod::Module, code::String, filename::String)
@ Base .\loading.jl:1116

Julia 1.6.6

EDMO_CODE = if length(varbyattrib(ds; long_name = "EDMO_code")) > 0

@Alexander-Barth
Copy link
Member

Alexander-Barth commented Sep 16, 2022

Even when by-passing the check of EDMO_CODE, I get an error when loading depth.
How come that you variable depth variable is not called "Depth" ? I only see these:

      float var20(N_STATIONS, N_SAMPLES) ;
                var20:long_name = "Depth [true depth, m], lat = 58.0168" ;
                var20:units = "" ;
                var20:comment = "" ;
                var20:ancillary_variables = "var20_qc" ;
                var20:C_format = "%.2f" ;
                var20:FORTRAN_format = "F12.2" ;
                var20:_FillValue = -1.e+10f ;

       float var19(N_STATIONS, N_SAMPLES) ;
                var19:long_name = "Depth [salt water, m], lat = 58.0168" ;
                var19:units = "" ;
                var19:comment = "" ;
                var19:ancillary_variables = "var19_qc" ;
                var19:C_format = "%.2f" ;
                var19:FORTRAN_format = "F12.2" ;
                var19:_FillValue = -1.e+10f ;

@MartinHanssonSMHI
Copy link
Author

MartinHanssonSMHI commented Oct 11, 2022 via email

@jmbeckers
Copy link
Member

I think in the old DIVA version we searched for depth and if not found used pressure instead. Would that be a solution or is it better to force DIVAnd users to stick to depth ?

@Alexander-Barth
Copy link
Member

Alexander-Barth commented Jan 12, 2023

Well depth is there, but it is not called in a way that we expected it in DIVAnd. Unfortunately, ODV does not use the CF standard names (nor the BODC names) so we have to rely on long_name, but this assumes that the long_name is consistently named (Depth as in the example files that I got from Reiner, but not Depth [true depth, m], lat = 58.0168). This should be easy that handle in ODV (outside of DIVAnd).

Please feel free to re-open if you have trouble renaming the attribute or ask in the ODV forum.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants