Explain how to read an ODV spreadsheet data file using Julia


In [47]:
include("./ODVspreadsheet.jl")
using Logging
using ODVspreadsheet


WARNING: replacing module ODVspreadsheet
WARNING: using ODVspreadsheet.readODVspreadsheet in module Main conflicts with an existing identifier.

Configuration

Logging


In [2]:
Logging.configure(level=WARNING);

Input file


In [32]:
datadir = "./";
ODVfile = joinpath(datadir, "BlackSea_2profiles.txt");

Check if the file exists:


In [33]:
if isfile(ODVfile)
    info("Working on file $ODVfile")
else
    err("File $ODVfile doesn't exist")
end

Read the file

The function will return an object that stores all the information contained in the spreadsheet.


In [34]:
ODVdata = readODVspreadsheet(ODVfile);

Check result

The labels of the columns. Note that some columns have the same title (quality flags).


In [35]:
ODVdata.columnLabels


Out[35]:
16-element Array{SubString{String},1}:
 "Cruise"                              
 "Station"                             
 "Type"                                
 "yyyy-mm-ddThh:mm:ss.sss"             
 "Longitude [degrees_east]"            
 "Latitude [degrees_north]"            
 "Bot. Depth [m]:METAVAR:FLOAT:4"      
 "Originator's Cruise:METAVAR:TEXT:20" 
 "Originator's Station:METAVAR:TEXT:20"
 "Depth [m]"                           
 "QV:WOD"                              
 "Temperature [C]"                     
 "QV:WOD"                              
 "Salinity [psu]"                      
 "QV:WOD"                              
 "QV:ODV:SAMPLE"                       

The metadata relative to the collection:


In [36]:
ODVdata.metadata


Out[36]:
Dict{String,String} with 9 entries:
  "DataType"               => "Profiles"
  "Source"                 => "/home/charles/DIVA/BlackSea4diva/New_ODV4_Collec…
  "DataField"              => "Ocean"
  "Software"               => "Ocean Data View Version 4.2.1 - 2009"
  "SourceLastModified"     => "2011-12-19T12:42:03"
  "Version"                => "ODV Spreadsheet V4.0"
  "Creator"                => "charles@gher13.phys.ulg.ac.be"
  "CreateTime"             => "2011-12-19T12:42:52"
  "MissingValueIndicators" => "-99"

The profiles. Here we only have 2 profiles so it's ok to display their content. Otherwise it is preferable to select one profile.


In [37]:
ODVdata.profileList


Out[37]:
2-element Array{Any,1}:
 Any[SubString{String}["WOD05_BG000003"],SubString{String}["11570900"],SubString{String}["B"],SubString{String}["1991-09-03T16:25"],SubString{String}["28.3333"],SubString{String}["43.167"],SubString{String}["36"],SubString{String}[""],SubString{String}["CoMSBlack91"],SubString{String}["0.0","10.0","20.0","30.0"],SubString{String}["0","0","0","0"],SubString{String}["22.208","22.260","22.346","22.308"],SubString{String}["0","0","0","0"],SubString{String}["15.7020","15.7380","15.9740","16.0270"],SubString{String}["0","0","0","0"],SubString{String}["1","1","1","1"]]                                                                                                                                                                                                                                                                                                    
 Any[SubString{String}["WOD05_BG000003"],SubString{String}["11570901"],SubString{String}["B"],SubString{String}["1991-09-03T21:10"],SubString{String}["28.8333"],SubString{String}["43.167"],SubString{String}["325"],SubString{String}[""],SubString{String}["CoMSBlack91"],SubString{String}["0.0","10.0","20.0","30.0","50.0","75.0","100.0","125.0","150.0","200.0","250.0"],SubString{String}["0","0","0","0","0","0","0","0","0","0","0"],SubString{String}["21.946","21.956","21.969","9.954","7.447","7.121","7.248","8.097","8.359","8.615","8.741"],SubString{String}["0","0","0","0","0","0","0","0","0","0","0"],SubString{String}["17.5830","17.5830","17.5870","18.0420","18.1402","18.3111","18.8920","20.3090","20.7490","21.2030","21.4960"],SubString{String}["0","0","0","0","0","0","0","0","0","0","0"],SubString{String}["1","1","1","1","1","1","1","1","1","1","1"]]

In [46]:
profile1 = ODVdata.profileList[1][end][1]


Out[46]:
"1"

If you want to access the temperature, you just need to know in which column it is stored.
It is easy if you use the columnLabels:


In [11]:
temperature = profile1[12]


Out[11]:
11-element Array{SubString{String},1}:
 "21.946"
 "21.956"
 "21.969"
 "9.954" 
 "7.447" 
 "7.121" 
 "7.248" 
 "8.097" 
 "8.359" 
 "8.615" 
 "8.741" 

Currently all the data are read as strings, but it's easy to convert them to floats.


In [12]:
map(x->parse(Float64,x),temperature)


Out[12]:
11-element Array{Float64,1}:
 21.946
 21.956
 21.969
  9.954
  7.447
  7.121
  7.248
  8.097
  8.359
  8.615
  8.741

In [24]:
length(ODVdata.metadata)


Out[24]:
9

In [ ]: