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

merge from upstream #137

Open
wants to merge 17 commits into
base: master
Choose a base branch
from
23 changes: 19 additions & 4 deletions codebase/apps/refractt/src/CalcNexrad/CalcNexrad.cc
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ using namespace std;
const string CalcNexrad::TIME_DIM_NAME = "Time";
const string CalcNexrad::GATES_DIM_NAME = "Gates";

string CalcNexrad::site = "KFTG";
const string CalcNexrad::I_VAR_NAME = "I";
const string CalcNexrad::Q_VAR_NAME = "Q";
const string CalcNexrad::SAMPLE_NUM_VAR_NAME = "SampleNum";
Expand All @@ -79,8 +80,8 @@ const string CalcNexrad::UNIX_TIME_VAR_NAME = "UnixTime";
const string CalcNexrad::NANO_SEC_VAR_NAME = "NanoSeconds";
const string CalcNexrad::FLAGS_VAR_NAME = "Flags";

const double CalcNexrad::RADAR_LAT = 39.7867;
const double CalcNexrad::RADAR_LON = -104.5458;
double CalcNexrad::RADAR_LAT = 39.7867;
double CalcNexrad::RADAR_LON = -104.5458;
const double CalcNexrad::RADAR_ALT = 1.7102;

const int CalcNexrad::NUM_AZIMUTHS = 360;
Expand Down Expand Up @@ -494,7 +495,21 @@ bool CalcNexrad::_processFile(const string &input_file_path)
input_file.close();
return false;
}

Nc3Att* nat=input_file.get_att("latitude") ;
RADAR_LAT=nat->values()->as_float(0);
nat=input_file.get_att("longitude");
RADAR_LON=nat->values()->as_float(0);
nat=input_file.get_att("site");
Nc3Values *values=nat->values();
int len=nat->num_vals();
char buf[32];
memset(buf,0,sizeof(buf));
for(int i=0;i<len;i++)
{
buf[i]=values->as_char(i);
}
site=string(buf);

if (time_dim->size() <= 0 || gates_dim->size() <= 0)
{
cerr << "ERROR: " << method_name << endl;
Expand Down Expand Up @@ -1016,7 +1031,7 @@ bool CalcNexrad::_writeSweepFile()
}
} /* endif - _params->debug */

SweepFile sweep_file(_args->getOutputDir(),
SweepFile sweep_file(_args->getOutputDir(), site,
RADAR_LAT, RADAR_LON, RADAR_ALT,
_sweepStartTime, _elevation[0],
0, 0,
Expand Down
6 changes: 4 additions & 2 deletions codebase/apps/refractt/src/CalcNexrad/CalcNexrad.hh
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ class CalcNexrad

static const string TIME_DIM_NAME;
static const string GATES_DIM_NAME;
static string site;

// Names of the variable fields in the netCDF file.

Expand All @@ -142,8 +143,8 @@ class CalcNexrad

// Constant radar values

static const double RADAR_LAT;
static const double RADAR_LON;
static double RADAR_LAT;
static double RADAR_LON;
static const double RADAR_ALT;

static const int NUM_AZIMUTHS;
Expand All @@ -153,6 +154,7 @@ class CalcNexrad
static const double POWER_CONSTANT;
static const double START_RANGE;
static const double GATE_SPACING;



/////////////////////
Expand Down
5 changes: 3 additions & 2 deletions codebase/apps/refractt/src/CalcNexrad/SweepFile.cc
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ const float SweepFile::MISSING_DATA_VALUE = -32768.0;
*/

SweepFile::SweepFile(const string &output_dir,
const string &site,
const double radar_lat, /* deg */
const double radar_lon, /* deg */
const double radar_alt, /* km */
Expand Down Expand Up @@ -115,8 +116,8 @@ SweepFile::SweepFile(const string &output_dir,
DateTime stime(sweep_start_time);
char path[MAX_PATH_LEN];
sprintf(path,
"%s/ncswp_KFTG_%.4d%.2d%.2d_%.2d%.2d%.2d.000_v%.3d_s%.2d_%.1f_SUR_.nc",
_outputDir.c_str(),
"%s/ncswp_%s_%.4d%.2d%.2d_%.2d%.2d%.2d.000_v%.3d_s%.2d_%.1f_SUR_.nc",
_outputDir.c_str(),site.c_str(),
stime.getYear(), stime.getMonth(), stime.getDay(),
stime.getHour(), stime.getMin(), stime.getSec(),
_volNum, _tiltNum, elev0);
Expand Down
1 change: 1 addition & 0 deletions codebase/apps/refractt/src/CalcNexrad/SweepFile.hh
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ public:
*/

SweepFile(const string &output_dir,
const string &site,
const double radar_lat, /* deg */
const double radar_lon, /* deg */
const double radar_alt, /* km */
Expand Down
196 changes: 196 additions & 0 deletions codebase/apps/refractt/src/Cinrad2CDFSweep/Args.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,196 @@
// *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
// ** Copyright UCAR (c) 1990 - 2016
// ** University Corporation for Atmospheric Research (UCAR)
// ** National Center for Atmospheric Research (NCAR)
// ** Boulder, Colorado, USA
// ** BSD licence applies - redistribution and use in source and binary
// ** forms, with or without modification, are permitted provided that
// ** the following conditions are met:
// ** 1) If the software is modified to produce derivative works,
// ** such modified software should be clearly marked, so as not
// ** to confuse it with the version available from UCAR.
// ** 2) Redistributions of source code must retain the above copyright
// ** notice, this list of conditions and the following disclaimer.
// ** 3) Redistributions in binary form must reproduce the above copyright
// ** notice, this list of conditions and the following disclaimer in the
// ** documentation and/or other materials provided with the distribution.
// ** 4) Neither the name of UCAR nor the names of its contributors,
// ** if any, may be used to endorse or promote products derived from
// ** this software without specific prior written permission.
// ** DISCLAIMER: THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS
// ** OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
// ** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
// *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/

// RCS info
// $Author: dixon $
// $Locker: $
// $Date: 2016/03/07 18:17:26 $
// $Id: Args.cc,v 1.5 2016/03/07 18:17:26 dixon Exp $
// $Revision: 1.5 $
// $State: Exp $

/**-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-**/
/*********************************************************************
* Args: class controlling the command line arguments for the
* program.
*
* RAP, NCAR, Boulder CO
*
* July 2005
*
* Nancy Rehak
*
*********************************************************************/

#include <fstream>
#include <iostream>
#include <string>
#include <cstring>
#include <unistd.h>
#include <cstdlib>

#include "Args.hh"

using namespace std;

/**********************************************************************
* Constructor
*/

Args::Args (int argc, char **argv, char *prog_name) :
_debug(false),
_progName(prog_name)
{
static const string method_name = "Args::Args ()";

// Intialize

bool okay = true;

TDRP_init_override(&override);

// search for command options

string tmp_str;

for (int i = 1; i < argc; i++)
{
if (strcmp(argv[i], "--") == 0 ||
strcmp(argv[i], "-help") == 0 ||
strcmp(argv[i], "-man") == 0)
{
_usage(stdout);
exit(0);
}
else if (strcmp(argv[i], "-debug") == 0)
{
tmp_str = "debug = true;";
TDRP_add_override(&override, tmp_str.c_str());
}
else if (strcmp(argv[i], "-i") == 0)
{
while (argc > i+1 &&
argv[i+1][0] != '-')
_inputFileList.push_back(argv[++i]);
}
else if (strcmp(argv[i], "-fl") == 0)
{
string input_file = argv[++i];

if (!_readFileListFile(input_file))
okay = false;
}
else if (strcmp(argv[i], "-o") == 0)
{
tmp_str = "output_dir = \"" + string(argv[++i]) + "\";";
TDRP_add_override(&override, tmp_str.c_str());
}
} /* i */

if (!okay)
{
_usage(stderr);
exit(-1);
}

}


/**********************************************************************
* Destructor
*/

Args::~Args(void)
{
}


/**********************************************************************
* Private Member Functions *
**********************************************************************/

/**********************************************************************
* _readFileListFile() - Read the file containing the list of input
* files to process.
*
* Returns true on success, false on failure.
*/

bool Args::_readFileListFile(const string &file_name)
{
static const string method_name = "Args::_readFileListFile()";

// Open the file list file

ifstream infile(file_name.c_str());
if (!infile.is_open())
{
cerr << "ERROR: " << method_name << endl;
cerr << "Error opening file list file: " << file_name << endl;

return false;
}

// Read and save the input file paths

char buffer[1024];

while (infile.getline(buffer, sizeof(buffer)))
_inputFileList.push_back(buffer);

infile.close();

return true;
}


/**********************************************************************
* _usage() - Print the usage for this program.
*/

void Args::_usage(FILE *stream)
{
fprintf(stream, "%s%s%s",
"This program reads netCDF floating point time-series files\n"
"produced by the NEXRAD A1DA converter program and calculates\n"
"the variables needed for the Frederic Fabry's refractivity\n"
"algorithm.\n"
"\n"
"Usage:\n\n", _progName.c_str(), " [options] as below:\n\n"
" [ --, -help, -man ] produce this list.\n"
" [ -debug ] print debug messages while processing\n"
" [ -i <file list> ] list of input files to process\n"
" [ -fl <file list file> ] name of file containing\n"
" the list of input files to process\n"
" This file should contain the fully\n"
" qualified file paths for all of the input\n"
" files to be processed, with each path on a\n"
" separate line.\n"
" [ -o <dir> ] output directory\n"
"\n"
);

TDRP_usage(stream);
}
Loading