本文整理汇总了C++中NcDim::is_valid方法的典型用法代码示例。如果您正苦于以下问题:C++ NcDim::is_valid方法的具体用法?C++ NcDim::is_valid怎么用?C++ NcDim::is_valid使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NcDim
的用法示例。
在下文中一共展示了NcDim::is_valid方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: err
void Regioner::createCohorList4Run(){
// read in a list of cohorts to run
//netcdf error
NcError err(NcError::silent_nonfatal);
//open file and check if valid
string filename = md.runchtfile;
NcFile runFile(filename.c_str(), NcFile::ReadOnly);
if(!runFile.is_valid()){
string msg = filename+" is not valid";
char* msgc = const_cast< char* > ( msg.c_str());
throw Exception(msgc, I_NCFILE_NOT_EXIST);
}
NcDim* chtD = runFile.get_dim("CHTID");
if(!chtD->is_valid()){
string msg="CHT Dimension is not valid in createCohortList4Run";
char* msgc = const_cast<char*> (msg.c_str());
throw Exception(msgc, I_NCDIM_NOT_EXIST);
}
NcVar* chtV = runFile.get_var("CHTID");
if(chtV==NULL){
string msg="Cannot get CHTID in createCohortList4Run ";
char* msgc = const_cast<char*> (msg.c_str());
throw Exception(msgc, I_NCVAR_NOT_EXIST);
}
int numcht = chtD->size();
int chtid = -1;
int chtid0 = -1;
int chtidx = -1;
for (int i=0; i<numcht; i++){
chtV->set_cur(i);
chtV->get(&chtid, 1);
runchtlist.push_back(chtid);
if (i==0) chtid0=chtid;
if (i==numcht-1) chtidx=chtid;
}
cout <<md.casename << ": " <<numcht <<" cohorts to be run @" <<md.runstages<< "\n";
cout <<" from: " <<chtid0<<" to: " <<chtidx <<"\n";
};
示例2: initSiteinFile
void SiteinInputer::initSiteinFile(string & dirfile){
siteinfname = dirfile;
NcError err(NcError::silent_nonfatal);
NcFile siteFile(siteinfname.c_str(), NcFile::ReadOnly);
if(!siteFile.is_valid()){
string msg = siteinfname+" is not valid";
char* msgc = const_cast< char* > ( msg.c_str());
throw Exception( msgc, I_NCFILE_NOT_EXIST);
}
NcDim* siteD = siteFile.get_dim("CHTID");
if(!siteD->is_valid()){
throw Exception("SITED Dimension is not Valid in siteinFile", I_NCDIM_NOT_EXIST);
}
}
示例3: NetCDFProduct
//
// Creates NetCDF product
//
bool NetCDFProduct(MSG_header *PRO_head, MSG_data* PRO_data,
int totalsegs, int *segsindexes,
MSG_header *header, MSG_data *msgdat)
{
struct tm *tmtime;
char NcName[1024];
char reftime[64];
char projname[16];
int wd, hg;
int bpp;
int ncal;
float *cal;
NcVar *ivar;
NcVar *tvar;
NcDim *tdim;
NcDim *ldim;
NcDim *cdim;
NcDim *caldim;
int npix = header[0].image_structure->number_of_columns;
int nlin = header[0].image_structure->number_of_lines;
size_t npixperseg = npix*nlin;
size_t total_size = totalsegs*npixperseg;
MSG_SAMPLE *pixels = new MSG_SAMPLE[total_size];
memset(pixels, 0, total_size*sizeof(MSG_SAMPLE));
size_t pos = 0;
for (int i = 0; i < totalsegs; i ++)
{
if (segsindexes[i] >= 0)
memcpy(pixels+pos, msgdat[segsindexes[i]].image->data,
npixperseg*sizeof(MSG_SAMPLE));
pos += npixperseg;
}
nlin = nlin*totalsegs;
// Manage subarea
if (is_subarea)
{
if (AreaLinStart < 0 ||
AreaLinStart > nlin - AreaNlin ||
AreaNlin > nlin - AreaLinStart)
{
std::cerr << "Wrong Subarea in lines...." << std::endl;
throw;
}
if (AreaPixStart < 0 ||
AreaPixStart > npix - AreaNpix ||
AreaNpix > npix - AreaPixStart)
{
std::cerr << "Wrong Subarea in Pixels...." << std::endl;
throw;
}
size_t newsize = AreaNpix * AreaNlin;
MSG_SAMPLE *newpix = new MSG_SAMPLE[newsize];
memset(newpix, 0, newsize*sizeof(MSG_SAMPLE));
for (int i = 0; i < AreaNlin; i ++)
memcpy(newpix + i * AreaNpix,
pixels + (AreaLinStart + i) * npix + AreaPixStart,
AreaNpix * sizeof(MSG_SAMPLE));
delete [ ] pixels;
pixels = newpix;
total_size = newsize;
}
else
{
AreaNpix = npix;
AreaNlin = nlin;
}
tmtime = PRO_data->prologue->image_acquisition.PlannedAquisitionTime.TrueRepeatCycleStart.get_timestruct( );
t_enum_MSG_spacecraft spc = header[0].segment_id->spacecraft_id;
uint_1 chn = header[0].segment_id->spectral_channel_id;
float sublon = header[0].image_navigation->subsatellite_longitude;
int cfac = header[0].image_navigation->column_scaling_factor;
int lfac = header[0].image_navigation->line_scaling_factor;
int coff = header[0].image_navigation->column_offset;
int loff = header[0].image_navigation->line_offset;
float sh = header[0].image_navigation->satellite_h;
char *channelstring = strdup(MSG_channel_name(spc, chn).c_str( ));
char *channel = chname(channelstring, strlen(channelstring) + 1);
// Build up output NetCDF file name and open it
sprintf( NcName, "%s_%4d%02d%02d_%02d%02d.nc", channel,
tmtime->tm_year + 1900, tmtime->tm_mon + 1, tmtime->tm_mday,
tmtime->tm_hour, tmtime->tm_min );
NcFile ncf ( NcName , NcFile::Replace );
if (! ncf.is_valid()) return false;
// Fill arrays on creation
ncf.set_fill(NcFile::Fill);
// Add Global Attributes
if (! ncf.add_att("Satellite", MSG_spacecraft_name(spc).c_str()))
return false;
//.........这里部分代码省略.........