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

Edits to gui to add buttons to clear plot and clear parameters, remov… #7

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Binary file modified data_reviews/data_reviews.mlapp
Binary file not shown.
33 changes: 22 additions & 11 deletions data_reviews/nc_reader.m
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@
% https://www.mathworks.com/help/parallel-computing/examples/process-big-data-in-the-cloud.html

% Get information about the NetCDF data file
fileInfo = ncinfo(filename);
fileInfo = h5info(filename);

% Extract the global and variable level attributes -- note, Matlab doesn't
% really support these very well, so their utility is limited.
%gAttributes = struct2table(fileInfo.Attributes);
vAttributes = {fileInfo.Variables.Attributes};
vAttributes = {fileInfo.Datasets.Attributes};

% Extract the variable names
varNames = string({fileInfo.Variables.Name});
varNames = string({fileInfo.Datasets.Name});

% test for presence of a variable called time
i = 1; test = 0;
Expand All @@ -28,14 +28,15 @@

% Create the datetime axis from the time variable (OMS++ uses 1970 and OOI
% uses 1900 as their pivot years).
nc_time = ncread(filename, 'time'); % obtain the time record
nc_time = h5read(filename, '/time'); % obtain the time record
test = nc_time(1) / 60 / 60 / 24 + datenum(1970, 1, 1, 0, 0, 0);
if test > now
nc_time = nc_time / 60 / 60 / 24 + datenum(1900, 1, 1, 0, 0, 0);
dt = datetime(1900, 1, 1, 'Format', 'dd-MMM-yyyy HH:mm:ss', ...
'TimeZone', 'UTC') + seconds(nc_time);
else
nc_time = nc_time / 60 / 60 / 24 + datenum(1970, 1, 1, 0, 0, 0);
dt = datetime(1970, 1, 1, 'Format', 'dd-MMM-yyyy HH:mm:ss', ...
'TimeZone', 'UTC') + seconds(nc_time);
end %if
dt = datetime(nc_time, 'ConvertFrom', 'datenum', 'TimeZone', 'UTC');
rowlength = length(dt);
clear test nc_time

Expand All @@ -49,7 +50,8 @@
continue
end %if
% read the variable from the NetCDF file
data = ncread(filename, varNames{k});
data = squeeze(h5read(filename, "/" + varNames{k}));
% pull out the variable units and comment attributes
if ~isempty(vAttributes{k})
attr = struct2table(vAttributes{k});
units = {''}; descr = {''};
Expand All @@ -62,17 +64,26 @@
end %if
end %for
end %if
[r, c] = size(data); % check the dimensions
% add the variable and attributes to the time table
[r, c] = size(data); % check the dimensions
if r == rowlength
% if the number of rows == the number of RowTimes, add the variable
% without modification.
t = addvars(t, data, 'NewVariableNames', varNames{k});
if strcmp(fileInfo.Datasets(k).Datatype.Class, 'H5T_STRING')
t = addvars(t, cell2mat(data), 'NewVariableNames', varNames{k});
else
t = addvars(t, data, 'NewVariableNames', varNames{k});
end %if
t.Properties.VariableUnits{varNames{k}} = units{:};
t.Properties.VariableDescriptions{varNames{k}} = descr{:};
elseif c == rowlength
% if the number of columns equals the RowTimes, rotate the variable
% before adding it so the row length matches the RowTimes
t = addvars(t, data', 'NewVariableNames', varNames{k});
if strcmp(fileInfo.Datasets(k).Datatype.Class, 'H5T_STRING')
t = addvars(t, cell2mat(data'), 'NewVariableNames', varNames{k});
else
t = addvars(t, data', 'NewVariableNames', varNames{k});
end %if
t.Properties.VariableUnits{varNames{k}} = units{:};
t.Properties.VariableDescriptions{varNames{k}} = descr{:};
elseif r == 1 && c == 1
Expand Down
15 changes: 13 additions & 2 deletions data_reviews/request_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import os
import sys

from ooi_data_explorations.common import m2m_request, m2m_collect
from ooi_data_explorations.common import m2m_request, m2m_collect, dt64_epoch

def request_data(site, node, sensor, method, stream, start, stop):
"""
Expand All @@ -30,7 +30,8 @@ def request_data(site, node, sensor, method, stream, start, stop):

# Use a regex tag to download the sensor data from the THREDDS catalog
# created by our request.
tag = ('.*{}.*\\.nc$'.format(sensor[3:8]))
#tag = ('.*{}.*\\.nc$'.format(sensor[3:8]))
tag = ('.*{}.*\\.nc$'.format(stream))
data = m2m_collect(r, tag)
return data

Expand Down Expand Up @@ -63,6 +64,16 @@ def main(argv):

# request the data
data = request_data(site, node, sensor, method, stream, start, stop)

# sort by the deployment number and then time
data = data.sortby(['deployment', 'time'])

# reset the time record to seconds since 1970 and update the attributes
data['time'] = dt64_epoch(data.time)
data.time.attrs['long_name'] = 'Time'
data.time.attrs['standard_name'] = 'time'
data.time.attrs['units'] = 'seconds since 1970-01-01 00:00:00 0:00'
data.time.attrs['calendar'] = 'gregorian'

# save the data to disk
nc_out = os.path.abspath(filename)
Expand Down