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

Feature 2040 parse timing #2048

Merged
merged 5 commits into from
Feb 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 12 additions & 11 deletions met/src/libcode/vx_data2d_nc_met/data2d_nc_met.cc
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,7 @@ void MetNcMetDataFile::dump(ostream & out, int depth) const {

////////////////////////////////////////////////////////////////////////

bool MetNcMetDataFile::data_plane(VarInfo &vinfo, DataPlane &plane)

{

bool MetNcMetDataFile::data_plane(VarInfo &vinfo, DataPlane &plane) {
bool status = false;
ConcatString req_time_str, data_time_str;
VarInfoNcMet * vinfo_nc = (VarInfoNcMet *) &vinfo;
Expand Down Expand Up @@ -221,14 +218,18 @@ int MetNcMetDataFile::data_plane_array(VarInfo &vinfo,

////////////////////////////////////////////////////////////////////////

int MetNcMetDataFile::index(VarInfo &vinfo){
int MetNcMetDataFile::index(VarInfo &vinfo) {

NcVarInfo *ncinfo = MetNc->find_var_name( vinfo.name().c_str() );

if( NULL == MetNc->find_var_name( vinfo.name().c_str() ) ) return -1;
if( !ncinfo ) return(-1);

if( ( vinfo.valid() && MetNc->ValidTime != vinfo.valid() ) ||
( vinfo.init() && MetNc->InitTime != vinfo.init() ) ||
( !is_bad_data(vinfo.lead()) && MetNc->lead_time() != vinfo.lead() ) )
return -1;
if( ( vinfo.valid() != 0 && ncinfo->ValidTime != vinfo.valid() ) ||
( vinfo.init() != 0 && ncinfo->InitTime != vinfo.init() ) ||
( !is_bad_data(vinfo.lead()) && ncinfo->lead_time() != vinfo.lead() ) )
return(-1);

return 0;
return(0);
}

////////////////////////////////////////////////////////////////////////
2 changes: 0 additions & 2 deletions met/src/libcode/vx_data2d_nc_met/data2d_nc_met.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ class MetNcMetDataFile : public Met2dDataFile {

MetNcFile * MetNc; // allocated


//
// set stuff
//
Expand All @@ -73,7 +72,6 @@ class MetNcMetDataFile : public Met2dDataFile {

int index(VarInfo &);


//
// do stuff
//
Expand Down
32 changes: 5 additions & 27 deletions met/src/libcode/vx_data2d_nc_met/met_file.cc
Original file line number Diff line number Diff line change
Expand Up @@ -201,9 +201,6 @@ Nvars = 0;

if ( Var ) { delete [] Var; Var = (NcVarInfo *) 0; }

ValidTime = (unixtime) 0;
InitTime = (unixtime) 0;

//
// done
//
Expand Down Expand Up @@ -298,9 +295,8 @@ for (j=0; j<Ndims; ++j) {
if ( is_bad_data(ill) ) get_att_unixtime( Var[j], init_time_att_name, ill);
if ( is_bad_data(vll) ) get_att_unixtime( Var[j], valid_time_att_name, vll);


if ( !is_bad_data(ill) ) InitTime = ill;
if ( !is_bad_data(vll) ) ValidTime = vll;
if ( !is_bad_data(ill) ) Var[j].InitTime = ill;
if ( !is_bad_data(vll) ) Var[j].ValidTime = vll;

StringArray dimNames;
get_dim_names(&v, &dimNames);
Expand Down Expand Up @@ -366,10 +362,6 @@ out << prefix << "Ydim = " << (Ydim ? GET_NC_NAME_P(Ydim) : "(nul)") << "\n";

out << prefix << "\n";

out << prefix << "Init Time = ";

unix_to_mdyhms(InitTime, month, day, year, hour, minute, second);

snprintf(junk, sizeof(junk), "%s %d, %d %2d:%02d:%02d", short_month_name[month], day, year, hour, minute, second);

out << junk << "\n";
Expand Down Expand Up @@ -421,20 +413,6 @@ return;
////////////////////////////////////////////////////////////////////////


int MetNcFile::lead_time() const

{

unixtime dt = ValidTime - InitTime;

return ( (int) dt );

}


////////////////////////////////////////////////////////////////////////


double MetNcFile::data(NcVar * var, const LongArray & a) const

{
Expand Down Expand Up @@ -805,9 +783,9 @@ found = data(info->var, a, plane);
// store the times
//

plane.set_init ( ValidTime - lead_time() );
plane.set_valid ( ValidTime );
plane.set_lead ( lead_time() );
plane.set_init ( info->InitTime );
plane.set_valid ( info->ValidTime );
plane.set_lead ( info->lead_time() );
plane.set_accum ( info->AccumTime );

//
Expand Down
12 changes: 0 additions & 12 deletions met/src/libcode/vx_data2d_nc_met/met_file.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,20 +59,8 @@ class MetNcFile {

void dump(ostream &, int = 0) const;


NcFile * Nc; // allocated

//
// time
//

unixtime ValidTime;

unixtime InitTime;

int lead_time () const; // seconds


//
// dimensions
//
Expand Down
27 changes: 26 additions & 1 deletion met/src/libcode/vx_nc_util/nc_var_info.cc
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ unixtime get_att_value_unixtime(const NcAtt *att) {


//
// Code for class NcNcVarInfo
// Code for class NcVarInfo
//


Expand Down Expand Up @@ -151,6 +151,10 @@ level_att.clear();

units_att.clear();

ValidTime = (unixtime) 0;

InitTime = (unixtime) 0;

AccumTime = 0;

Ndims = 0;
Expand Down Expand Up @@ -199,6 +203,12 @@ else out << "(nul)";
if ( units_att.length() > 0 ) out << '\"' << units_att << '\"';
else out << "(nul)";

out << prefix << "ValidTime = " << unix_to_yyyymmdd_hhmmss(ValidTime)
<< " (" << ValidTime << ")\n";

out << prefix << "InitTime = " << unix_to_yyyymmdd_hhmmss(InitTime)
<< " (" << InitTime << ")\n";

out << prefix << "AccumTime = " << AccumTime;

out << "\n";
Expand Down Expand Up @@ -232,6 +242,17 @@ return;

}

////////////////////////////////////////////////////////////////////////


int NcVarInfo::lead_time() const

{

return ( (int) (ValidTime - InitTime) );

}


////////////////////////////////////////////////////////////////////////

Expand All @@ -254,6 +275,10 @@ level_att = i.level_att;

units_att = i.units_att;

ValidTime = i.ValidTime;

InitTime = i.InitTime;

AccumTime = i.AccumTime;

Ndims = i.Ndims;
Expand Down
6 changes: 6 additions & 0 deletions met/src/libcode/vx_nc_util/nc_var_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,14 @@ class NcVarInfo {

ConcatString units_att;

unixtime ValidTime;

unixtime InitTime;

int AccumTime; // seconds

int lead_time () const; // seconds

int Ndims;

NcDim ** Dims; // allocated
Expand Down