From 84380838b0b460cf61ce7dd3f8e16339c8c3da2c Mon Sep 17 00:00:00 2001 From: tfinney9 Date: Fri, 29 Jun 2018 10:53:27 -0600 Subject: [PATCH] updated CMakeLists.txt to include new weather files, get rid of old ones, removed unused icons, removed pointInputDelegate and pointDataModel as they are not used anymore, cleaned up cli. --- CMakeLists.txt | 27 +++- data/cli_momentumSolver_diurnal.cfg | 4 +- images/icons/transmit.png | Bin 749 -> 0 bytes images/icons/transmit_blue.png | Bin 814 -> 0 bytes images/icons/world.png | Bin 923 -> 0 bytes src/gui/CMakeLists.txt | 4 - src/gui/mainWindow.cpp | 51 ++---- src/gui/pointDataModel.cpp | 154 ------------------ src/gui/pointDataModel.h | 69 -------- src/gui/pointInput.cpp | 27 ++-- src/gui/pointInput.h | 2 - src/gui/pointInputDelegate.cpp | 241 ---------------------------- src/gui/pointInputDelegate.h | 65 -------- src/gui/stationFetchWidget.cpp | 56 ++++--- src/ninja/cli.cpp | 67 +++----- src/ninja/pointInitialization.cpp | 226 +++++++++----------------- wn-resources.qrc | 76 ++++----- 17 files changed, 218 insertions(+), 851 deletions(-) delete mode 100644 images/icons/transmit.png delete mode 100644 images/icons/transmit_blue.png delete mode 100644 images/icons/world.png delete mode 100644 src/gui/pointDataModel.cpp delete mode 100644 src/gui/pointDataModel.h delete mode 100644 src/gui/pointInputDelegate.cpp delete mode 100644 src/gui/pointInputDelegate.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 851068215..99d334d47 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -356,20 +356,41 @@ if(VERBOSE_CMAKE) endif(VERBOSE_CMAKE) # install target related files -set(etc_files mackay.tif +set(etc_files missoula_valley.tif example_lcp.lcp example_lcp.prj cli_domainAverage.cfg cli_domainAverage_diurnal.cfg cli_pointInitialization_diurnal.cfg cli_wxModelInitialization_diurnal.cfg - cli_momentumSolver_diurnal.cfg - mackay_wx_stations.csv) + cli_momentumSolver_diurnal.cfg) foreach(f ${etc_files}) install(FILES ${PROJECT_SOURCE_DIR}/data/${f} DESTINATION etc/windninja/example-files COMPONENT apps) endforeach(f ${etc_files}) +#add weather station files to example files +set(wx_station_current_files WXSTATIONS-2018-06-25-1237-missoula_valley/missoula_valley_stations_4.csv + WXSTATIONS-2018-06-25-1237-missoula_valley/KMSO-2018-06-25_1237-0.csv + WXSTATIONS-2018-06-25-1237-missoula_valley/PNTM8-2018-06-25_1237-2.csv + WXSTATIONS-2018-06-25-1237-missoula_valley/TR266-2018-06-25_1237-3.csv + WXSTATIONS-2018-06-25-1237-missoula_valley/TS934-2018-06-25_1237-1.csv) +foreach(f ${wx_station_current_files}) + install(FILES ${PROJECT_SOURCE_DIR}/data/${f} DESTINATION + etc/windninja/example-files/WXSTATIONS-2018-06-25-1237-missoula_valley COMPONENT apps) +endforeach(f ${wx_station_current_files}) + +#add weather station time series files +set(wx_station_ts_files WXSTATIONS-MDT-2018-06-20-2128-2018-06-21-2128-missoula_valley/missoula_valley_stations_4.csv + WXSTATIONS-MDT-2018-06-20-2128-2018-06-21-2128-missoula_valley/KMSO-MDT-2018-06-20_2128-2018-06-21_2128-0.csv + WXSTATIONS-MDT-2018-06-20-2128-2018-06-21-2128-missoula_valley/PNTM8-MDT-2018-06-20_2128-2018-06-21_2128-2.csv + WXSTATIONS-MDT-2018-06-20-2128-2018-06-21-2128-missoula_valley/TR266-MDT-2018-06-20_2128-2018-06-21_2128-3.csv + WXSTATIONS-MDT-2018-06-20-2128-2018-06-21-2128-missoula_valley/TS934-MDT-2018-06-20_2128-2018-06-21_2128-1.csv) +foreach(f ${wx_station_ts_files}) + install(FILES ${PROJECT_SOURCE_DIR}/data/${f} DESTINATION + etc/windninja/example-files/WXSTATIONS-MDT-2018-06-20-2128-2018-06-21-2128-missoula_valley COMPONENT apps) +endforeach(f ${wx_station_ts_files}) + set(share_files date_time_zonespec.csv tz_world.zip landfire.zip diff --git a/data/cli_momentumSolver_diurnal.cfg b/data/cli_momentumSolver_diurnal.cfg index 373469b6d..384b411f5 100644 --- a/data/cli_momentumSolver_diurnal.cfg +++ b/data/cli_momentumSolver_diurnal.cfg @@ -6,11 +6,11 @@ # num_threads = 1 -elevation_file = data/big_butte.tif +elevation_file = data/missoula_valley.tif initialization_method = domainAverageInitialization momentum_solver = true number_of_iterations = 2000 -mesh_choice = fine +mesh_choice = fine time_zone = America/Denver input_speed = 10.0 input_speed_units = mph diff --git a/images/icons/transmit.png b/images/icons/transmit.png deleted file mode 100644 index f54bf736cdc0d58a07c0a0171cc5a25b5e007e0e..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 749 zcmVIO@l#-%@K+Q7zAyIUxr7=;KLsPe99&9Qy zmp_aWYb=E&ic)qE1ceaTL3I)s3+v0Pdzpnl)xpCDFYk3f*Ymue2{3J{X-|sELAYmu z=`Mqi(_pe~fr(oVM(R_x-rovW3XC#01TV%_L0BAvr#_hKf!+|yzTW7{?3 zIuq0Vz);x1M>XE7-^4 zB)oZq-|zSSd<|RjL3Q0FaG93$Sb#=w6_iQ0NQ>FM@oa+ksPjrN7+e#)=Jk5tx!vxB zO+TG2$)d_PZTpo~g1ZG9e0&b?=MikQx3}AOy1Ns6Sn&5>og;!Hg4gVJ`{#y+hUEVS z2o4GUBDiwY}B+wa2=)lh*=g2T3C=Dq fF3wcNZJhl8^(M*LyGLEt00000NkvXXu0mjfpmtoM diff --git a/images/icons/transmit_blue.png b/images/icons/transmit_blue.png deleted file mode 100644 index 7b1142fc70adfd598ce6eac581421d7e6295f370..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 814 zcmV+}1JV46P)^~)@W#UgN8qC(979%Vy9NAeJn`# zSw2!>g&{fNR2$Okoji4(4lt5P$>r&q16P0#(CAS`X1XUkTWj$WH+~m^i1nA!c54U2@ zzUeSE3@r(@mOzU7Ss)3zO6X49?eVdR`>f= zD(&<}w=25V_BpD%QfK~{4*0vpV)<6BAI*U7!YSn(9anIo^h$1Lw4>$RCWGxdm8_qj z8-Z>jbWcRL3)o3FSHo3#4@0T!b!F!4__T7a7X3qJoMEqHkXET~kf2YcP!3qAt)$FI)g zfX4xE%Ve@IB_$;X{~G{!1n^hDt+6w}2Edy|MMdmC0|1`~><4@={vu#`et!O#R4P65 s*8sp^b=iB(8ZE$Cxw*NSsD#+rPu4uZkAluh`2YX_07*qoM6N<$g1stv`v3p{ diff --git a/images/icons/world.png b/images/icons/world.png deleted file mode 100644 index 68f21d30116710e48a8bf462cb32441e51fad5f6..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 923 zcmV;M17!S(P)A9)b<7tX~vT z$e)FfZ+`X4_uKyq#wJHC;J3lH{lhQkUc~Wid;*pnjhM12xe-bPByd^xuQ9zgeM^Mm z*tc)|P}LtTnHXr@Gkmmbkg^O2bqyhO>LP|qjIwW2@Di+4EuKm~&tOO2!N3o{128Hl z9v%fgerM0C#)7P|PMvxr*!Gf?eGA8f{OT6fS`9l>LQCg)p=~c$Zr|AT_0+_?F*JJk zlapOT2Q(wWx-LMq(TxXxLn+U;!LV)MhNp~ommdh+fo8T*&g-yQbbG&ze&=>tC(Ar=&^1xlA;Jc(6 zcCi_xs8k}-S&#ONOHm%e@#nGC7F++8C~r29Or!_{(QGQEG)+O^J1BCPmgM4JAzC8I z`jS9bO>|}Jq_#$IRzp0d34>)&3L%7MN)eTv!0B!^nn}f4z2*vFE@jv3dn zG>H)u>FR7_d2JcsjvfZ$vkP~xik@T^(_N)nx=tqJV+tQjQ`owJ83bf`zX6Ear*=Mhzn5QUuXE|v zR33Qyi8G!0{H2r##d#6R6YmYbZz4NTssT;cXiGb6lxO+k@{ba@2D~*hKDY6N;Bkh> xhhCRLejsJkAIT{5sICHcfU`5>bKmUb{{y)0nR3PMMxX!y002ovPDHLkV1nl+t-}BS diff --git a/src/gui/CMakeLists.txt b/src/gui/CMakeLists.txt index 9befe2c93..5f573ee24 100644 --- a/src/gui/CMakeLists.txt +++ b/src/gui/CMakeLists.txt @@ -34,8 +34,6 @@ set(NINJA_GUI_INCLUDES consoleDockWidget.h outputHeightWidget.h outputMetaData.h pdfOutput.h - pointDataModel.h - pointInputDelegate.h pointInput.h shapeOutput.h solvePage.h @@ -82,9 +80,7 @@ set(NINJA_GUI_SOURCES cmake_gui.cpp nativeSolverInput.cpp ninjafoamInput.cpp pdfOutput.cpp - pointDataModel.cpp pointInput.cpp - pointInputDelegate.cpp shapeOutput.cpp solvePage.cpp solveThread.cpp diff --git a/src/gui/mainWindow.cpp b/src/gui/mainWindow.cpp index aa092ec10..58e4e1f0f 100644 --- a/src/gui/mainWindow.cpp +++ b/src/gui/mainWindow.cpp @@ -1907,12 +1907,12 @@ int mainWindow::solve() int pointFormat = tree->point->simType; std::vector pointFileList = tree->point->stationFileList; //This is for the new way std::string pointFile = tree->point->stationFileList[0]; //For Old Format, only can accept 1 file - std::vector xStartTime = tree->point->startSeries; - std::vector xEndTime = tree->point->endSeries; - int numTimeSteps = tree->point->numSteps->value(); - bool useTimeList = tree->point->enableTimeseries; - bool writeStationKML = tree->point->writeStationKmlButton->isChecked(); - bool writeStationCSV = tree->point->writeStationFileButton->isChecked(); + std::vector xStartTime = tree->point->startSeries; //Get the start time from pointInput + std::vector xEndTime = tree->point->endSeries; //Get the Stop time from pointInput + int numTimeSteps = tree->point->numSteps->value(); //Get the number of steps from pointInput + bool useTimeList = tree->point->enableTimeseries; //Find out if its a timeseries run or not + bool writeStationKML = tree->point->writeStationKmlButton->isChecked(); //Write a kml file + bool writeStationCSV = tree->point->writeStationFileButton->isChecked(); //hidden for now /* * Note that pointFormat is not the same as stationFormat! @@ -1971,9 +1971,7 @@ int mainWindow::solve() QMessageBox::Ok | QMessageBox::Default); disconnect(progressDialog, SIGNAL(canceled()), this, SLOT(cancelSolve())); - setCursor(Qt::ArrowCursor); - setCursor(Qt::ArrowCursor); - tree->weather->checkForModelData(); + setCursor(Qt::ArrowCursor); //Restart everything progressDialog->cancel(); progressDialog->hide(); delete army; @@ -1988,7 +1986,7 @@ int mainWindow::solve() std::vector formatVec; std::vector timeList; CPLDebug("STATION_FETCH","NEW FORMAT..."); - for (int i=0;iweather->checkForModelData(); progressDialog->cancel(); progressDialog->hide(); delete army; @@ -2046,8 +2042,10 @@ int mainWindow::solve() boost::posix_time::ptime noTime; CPLDebug("STATION_FETCH","USING CURRENT WEATHER DATA..."); std::vector xSingleTime = tree->point->diurnalTimeVec; - boost::posix_time::ptime singleTime = pointInitialization::generateSingleTimeObject(xSingleTime[0],xSingleTime[1],xSingleTime[2],xSingleTime[3],xSingleTime[4],timeZone); - timeList.push_back(singleTime); + boost::posix_time::ptime singleTime = pointInitialization::generateSingleTimeObject(xSingleTime[0], + xSingleTime[1],xSingleTime[2], + xSingleTime[3],xSingleTime[4],timeZone); + timeList.push_back(singleTime); pointInitialization::storeFileNames(pointFileList); try{ //try making the army with current data army->makeStationArmy(timeList,timeZone,pointFileList[0],demFile,true,false); @@ -2063,8 +2061,6 @@ int mainWindow::solve() disconnect(progressDialog, SIGNAL(canceled()), this, SLOT(cancelSolve())); setCursor(Qt::ArrowCursor); - setCursor(Qt::ArrowCursor); - tree->weather->checkForModelData(); progressDialog->cancel(); progressDialog->hide(); delete army; @@ -2105,7 +2101,7 @@ int mainWindow::solve() } const char *metaOpt = CPLGetConfigOption("FETCH_METADATA","FALSE"); if(metaOpt!="FALSE") //set a config option to get the metadata from the DEM - { //There is also a button for this, that is hidden + { //There is also a button for this, that is hidden (see stationFetchWidget) writeToConsole("Fetching station metadata for DEM..."); QString demBase = QFileInfo(QString(demFile.c_str())).baseName(); QString demPath = QFileInfo(demFile.c_str()).absoluteDir().absolutePath()+"/"; @@ -2213,21 +2209,8 @@ int mainWindow::solve() } if( initMethod == WindNinjaInputs::pointInitializationFlag ) //Moved to makeStationArmy { -// if( NINJA_SUCCESS != army->setWxStationFilename( i, pointFile ) ) -// { -// QMessageBox::critical( this, -// tr("Invalid Point inititialization file" ), -// tr( "Invalid Point initialization file" ), -// QMessageBox::Ok | QMessageBox::Default ); -// disconnect(progressDialog, SIGNAL(canceled()), this, SLOT(cancelSolve())); -// setCursor(Qt::ArrowCursor); -// tree->weather->checkForModelData(); -// progressDialog->cancel(); -// delete army; -// return false; -// } + } - else if( initMethod == WindNinjaInputs::domainAverageInitializationFlag ) { //get speed @@ -2305,12 +2288,6 @@ int mainWindow::solve() } else if( initMethod == WindNinjaInputs::pointInitializationFlag ) //Moved to makeStationArmy { -// army->setDateTime( 0, tree->point->dateTimeEdit->date().year(), -// tree->point->dateTimeEdit->date().month(), -// tree->point->dateTimeEdit->date().day(), -// tree->point->dateTimeEdit->time().hour(), -// tree->point->dateTimeEdit->time().minute(), -// 0, timeZone ); army->setPosition( i, GDALCenterLat, GDALCenterLon ); } } diff --git a/src/gui/pointDataModel.cpp b/src/gui/pointDataModel.cpp deleted file mode 100644 index 3c70539b1..000000000 --- a/src/gui/pointDataModel.cpp +++ /dev/null @@ -1,154 +0,0 @@ -/****************************************************************************** - * - * $Id $ - * - * Project: WindNinja Qt GUI - * Purpose: Point data model. - * Author: Kyle Shannon - * - ****************************************************************************** - * - * THIS SOFTWARE WAS DEVELOPED AT THE ROCKY MOUNTAIN RESEARCH STATION (RMRS) - * MISSOULA FIRE SCIENCES LABORATORY BY EMPLOYEES OF THE FEDERAL GOVERNMENT - * IN THE COURSE OF THEIR OFFICIAL DUTIES. PURSUANT TO TITLE 17 SECTION 105 - * OF THE UNITED STATES CODE, THIS SOFTWARE IS NOT SUBJECT TO COPYRIGHT - * PROTECTION AND IS IN THE PUBLIC DOMAIN. RMRS MISSOULA FIRE SCIENCES - * LABORATORY ASSUMES NO RESPONSIBILITY WHATSOEVER FOR ITS USE BY OTHER - * PARTIES, AND MAKES NO GUARANTEES, EXPRESSED OR IMPLIED, ABOUT ITS QUALITY, - * RELIABILITY, OR ANY OTHER CHARACTERISTIC. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - * - *****************************************************************************/ - -/** - * @file pointInput.cpp - * @author Kyle Shannon - */ - -#include "pointDataModel.h" - -/** - * - * @param parent - */ -pointDataModel::pointDataModel( QObject *parent ) : - QAbstractItemModel( parent ) -{ - header << "Station" << "Value"; -} - -pointDataModel::~pointDataModel() -{ - -} - -QVariant pointDataModel::data( const QModelIndex &index, int role ) const -{ - double dfTemp = 0; - int row = index.row(); - int col = index.column(); - wxStation station = stations[row]; - if( role == Qt::DisplayRole ) { - if( col == 0 ) - return QVariant( station.get_stationName().c_str() ); - else if ( col == 1 ) { - if( station.get_coordType() == wxStation::PROJCS ) - return QVariant( "PROJCS" ); - else if( station.get_coordType() == wxStation::GEOGCS ) - return QVariant( "GEOGCS" ); - } - else if( col == 2 ) { - if( station.get_datumType() == wxStation::WGS84 ) - return QVariant( "WGS84" ); - else if( station.get_datumType() == wxStation::NAD83 ) - return QVariant( "NAD83" ); - else if( station.get_datumType() == wxStation::NAD27 ) - return QVariant( "NAD27" ); - } - else if( col == 3 ) { - if( station.get_coordType() == wxStation::GEOGCS ) - return QVariant( station.get_lat( ) ); - else if ( station.get_coordType() == wxStation::PROJCS ) - return QVariant( station.get_projYord( ) ); - else - return QVariant(); - } - else if( col == 4 ) - return QVariant( station.get_lon() ); - else if( col == 5 ) - return QVariant( station.get_height() ); - else if( col == 6 ) - return QVariant( "meters" ); - else if( col == 7 ) - return QVariant( station.get_speed() ); - else if( col == 8 ) - return QVariant( "mps" ); - else if( col == 9 ) - return QVariant( station.get_direction() ); - else if( col == 10 ) - return QVariant( station.get_temperature() ); - else if( col == 11 ) - return QVariant( "K" ); - else if( col == 12 ) - return QVariant( station.get_cloudCover() * 100 ); - else if( col ==13 ) { - dfTemp = station.get_influenceRadius(); - if( dfTemp < 0 ) - dfTemp = -1; - return QVariant( dfTemp ); - } - else if( col == 14 ) - return QVariant( "meters" ); - else - return QVariant(); - } - return QVariant( ); -} - -QModelIndex pointDataModel::parent( const QModelIndex & index ) const -{ - return QModelIndex(); -} - -QModelIndex pointDataModel::index ( int row, int column, - const QModelIndex & parent ) const -{ - return QModelIndex(); -} - -QVariant pointDataModel::headerData( int section, Qt::Orientation orientation, - int role ) const -{ - if( role == Qt::DisplayRole ) { - if( orientation == Qt::Horizontal ) - return QVariant( header[section] ); - else if( orientation == Qt::Vertical ) - return QVariant( section + 1 ); - else - return QVariant(); - } - else - return QVariant(); -} - -int pointDataModel::rowCount(const QModelIndex &parent ) const -{ - return stations.size(); -} - -int pointDataModel::columnCount(const QModelIndex &parent ) const -{ - return header.size(); -} - -void pointDataModel::update() -{ - reset(); -} diff --git a/src/gui/pointDataModel.h b/src/gui/pointDataModel.h deleted file mode 100644 index e1e4b9d1c..000000000 --- a/src/gui/pointDataModel.h +++ /dev/null @@ -1,69 +0,0 @@ -/****************************************************************************** - * - * $Id$ - * - * Project: WindNinja Qt GUI - * Purpose: Point data model. - * Author: Kyle Shannon - * - ****************************************************************************** - * - * THIS SOFTWARE WAS DEVELOPED AT THE ROCKY MOUNTAIN RESEARCH STATION (RMRS) - * MISSOULA FIRE SCIENCES LABORATORY BY EMPLOYEES OF THE FEDERAL GOVERNMENT - * IN THE COURSE OF THEIR OFFICIAL DUTIES. PURSUANT TO TITLE 17 SECTION 105 - * OF THE UNITED STATES CODE, THIS SOFTWARE IS NOT SUBJECT TO COPYRIGHT - * PROTECTION AND IS IN THE PUBLIC DOMAIN. RMRS MISSOULA FIRE SCIENCES - * LABORATORY ASSUMES NO RESPONSIBILITY WHATSOEVER FOR ITS USE BY OTHER - * PARTIES, AND MAKES NO GUARANTEES, EXPRESSED OR IMPLIED, ABOUT ITS QUALITY, - * RELIABILITY, OR ANY OTHER CHARACTERISTIC. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - * - *****************************************************************************/ - -#ifndef POINT_DATA_MODEL_H -#define POINT_DATA_MODEL_H - -#include -#include -#include -#include - -#include - -#include -#include "wxStation.h" - -class pointDataModel : public QAbstractItemModel -{ - Q_OBJECT - - public: - pointDataModel( QObject *parent = 0 ); - ~pointDataModel(); - - //Read Only MVC - - QModelIndex index ( int row, int column, - const QModelIndex & parent = QModelIndex() ) const; - QModelIndex parent ( const QModelIndex & index ) const; - - int rowCount( const QModelIndex &parent = QModelIndex() ) const; - int columnCount( const QModelIndex &parent = QModelIndex() ) const; - - QVariant headerData ( int section, Qt::Orientation orientation, - int role = Qt::DisplayRole ) const; - QVariant data( const QModelIndex &index, int role = Qt::DisplayRole ) const; - - void update(); - - std::vector stations; - QStringList header; -}; -#endif /* POINT_DATA_MODEL_H */ diff --git a/src/gui/pointInput.cpp b/src/gui/pointInput.cpp index 3638d0398..676a1260d 100644 --- a/src/gui/pointInput.cpp +++ b/src/gui/pointInput.cpp @@ -257,7 +257,7 @@ pointInput::pointInput( QWidget *parent ) : QWidget( parent ) this, SLOT(checkForModelData())); connect(startTime,SIGNAL(dateTimeChanged(QDateTime)),this,SLOT(updateStartTime(QDateTime))); //update time into a vector from the timeboxes connect(stopTime,SIGNAL(dateTimeChanged(QDateTime)),this,SLOT(updateStopTime(QDateTime))); - connect(stopTime,SIGNAL(dateTimeChanged(QDateTime)),this,SLOT(watchStopTime())); + connect(stopTime,SIGNAL(dateTimeChanged(QDateTime)),this,SLOT(watchStopTime()));//Watch the times to make sure the user can't do crazy things connect(startTime,SIGNAL(dateTimeChanged(QDateTime)),this,SLOT(watchStartTime())); connect(treeView->selectionModel(), SIGNAL(selectionChanged(const QItemSelection &,const QItemSelection &)), @@ -335,17 +335,17 @@ void pointInput::readStationFiles(const QItemSelection &x ,const QItemSelection stationFileList = selectedStations; stationFileTypes = vecInt; - if (vecInt.size()>1) + if (vecInt.size()>1) //Set the simulation type to -1 -> user selects different file types { simType = -1; - displayInformation(-1); + displayInformation(-1); //Display some information to the console } - if (vecInt.size()==1) + if (vecInt.size()==1) //Set the sim type to whatever it is { simType = vecInt[0]; displayInformation(vecInt[0]); } - else + else //we probably failed to open it because its a bad file { simType = -1; displayInformation(-1); @@ -406,9 +406,9 @@ int pointInput::directStationTraffic(const char* xFileName) idx2 = poLayer->GetFeatureCount(); - CPLDebug("STATION_FETCH","Number of Time Entries: %llu",idx2); + CPLDebug("STATION_FETCH","Number of Time Entries: %llu",idx2); //How many lines are on disk QString qFileName = QFileInfo(xFileName).fileName(); - writeToConsole(QString(qFileName+" has: "+QString::number(idx2)+" time entries")); + writeToConsole(QString(qFileName+" has: "+QString::number(idx2)+" time entries")); //tell the user in the console const char* emptyChair; //Muy Importante! poFeature = poLayer->GetFeature(iBig); @@ -425,11 +425,6 @@ int pointInput::directStationTraffic(const char* xFileName) CPLDebug("STATION_FETCH","STATION START TIME: %s",start_datetime.c_str()); CPLDebug("STATION_FETCH","STATION END TIME: %s",stop_datetime.c_str()); -// writeToConsole(QString(qFileName+"\nfirst time: "+start_datetime.c_str())); -// writeToConsole(QString(qFileName+"\nlaste Time: "+stop_datetime.c_str())); -// writeToConsole("Start Time (UTC): "+QString(start_datetime.c_str())); -// writeToConsole("Stop Time (UTC): "+QString(stop_datetime.c_str())); - if (start_datetime.empty()==true && stop_datetime.empty()==true) { //Means that there is not a time series @@ -453,7 +448,7 @@ int pointInput::directStationTraffic(const char* xFileName) //Old Format //Prevent users from using time series with old format enableTimeseries=false; - startTime->setEnabled(false); + startTime->setEnabled(false); //Hide these things because its an old format run stopTime->setEnabled(false); numSteps->setEnabled(false); @@ -599,7 +594,7 @@ void pointInput::readStationTime(string start_time, string stop_time, int xSteps startTime->setDateTime(loc_start_time); stopTime->setDateTime(loc_end_time); //Updates date time based on disk information - updateTimeSteps(); + updateTimeSteps(); //Calculate how many steps we can do between the start and stop time } /** * @brief pointInput::displayInformation @@ -672,7 +667,7 @@ void pointInput::displayInformation(int dataType) QDateTime pointInput::readNinjaNowName(const char *fileName) { CPLDebug("STATION_FETCH","Reading 1 step Station start Time"); - QDateTime qxDate = QFileInfo(fileName).created(); + QDateTime qxDate = QFileInfo(fileName).created(); //Get when the file was created because that is when the simulation time is return qxDate; } /** @@ -712,7 +707,7 @@ void pointInput::selChanged(const QItemSelection &x, const QItemSelection &y) // CPLDebug("STATION_FETCH","TEST"); } -void pointInput::openMainWindow() +void pointInput::openMainWindow() //This is for opening and closing the station-fetch widget { this->setEnabled(true); } diff --git a/src/gui/pointInput.h b/src/gui/pointInput.h index 0dbcabfd6..b920809ee 100644 --- a/src/gui/pointInput.h +++ b/src/gui/pointInput.h @@ -53,8 +53,6 @@ #include -#include "pointDataModel.h" -#include "pointInputDelegate.h" #include "latLonWidget.h" #include "wxStation.h" #include "ninjaUnits.h" diff --git a/src/gui/pointInputDelegate.cpp b/src/gui/pointInputDelegate.cpp deleted file mode 100644 index e3bea2723..000000000 --- a/src/gui/pointInputDelegate.cpp +++ /dev/null @@ -1,241 +0,0 @@ -/****************************************************************************** - * - * $Id$ - * - * Project: WindNinja Qt GUI - * Purpose: Point initialization delegate. - * Author: Kyle Shannon - * - ****************************************************************************** - * - * THIS SOFTWARE WAS DEVELOPED AT THE ROCKY MOUNTAIN RESEARCH STATION (RMRS) - * MISSOULA FIRE SCIENCES LABORATORY BY EMPLOYEES OF THE FEDERAL GOVERNMENT - * IN THE COURSE OF THEIR OFFICIAL DUTIES. PURSUANT TO TITLE 17 SECTION 105 - * OF THE UNITED STATES CODE, THIS SOFTWARE IS NOT SUBJECT TO COPYRIGHT - * PROTECTION AND IS IN THE PUBLIC DOMAIN. RMRS MISSOULA FIRE SCIENCES - * LABORATORY ASSUMES NO RESPONSIBILITY WHATSOEVER FOR ITS USE BY OTHER - * PARTIES, AND MAKES NO GUARANTEES, EXPRESSED OR IMPLIED, ABOUT ITS QUALITY, - * RELIABILITY, OR ANY OTHER CHARACTERISTIC. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - * - *****************************************************************************/ - -/** - * @file pointInputDelegate.cpp - * @author Kyle Shannon - */ -#include "pointInputDelegate.h" - -/** - * Constructor for the delegate representing a weather station - * @param parent: pointer to the parent of the widget - * @see QItemDelegate - */ -pointInputDelegate::pointInputDelegate( QObject *parent ) : - QItemDelegate( parent ) -{ - -} - -/** - * Assigns the widget to display based on the column in the table. - * Combo boxes are used for units, spin boxes for values. The station - * name is defaulted to the QItemDelegate::createEditor() - * @param parent: pointer to the parent of the widget - * @param QStyleOptionViewItem: unused - * @param index: index to the row(unused) and column for the editor to be - * placed - * @return QWidget to place in the view based on column - */ -QWidget *pointInputDelegate::createEditor( QWidget *parent, - const QStyleOptionViewItem &option, - const QModelIndex &index ) const -{ - if( index.column() == 1 ) { - QComboBox *comboBox = new QComboBox( parent ); - comboBox->addItem( "PROJCS" ); - comboBox->addItem( "GEOGCS" ); - return comboBox; - } - else if( index.column() == 2 ) { - QComboBox *comboBox = new QComboBox( parent ); - comboBox->addItem( "WGS84" ); - comboBox->addItem( "NAD83" ); - comboBox->addItem( "NAD27" ); - return comboBox; - } - else if( index.column() == 3 ) { - QDoubleSpinBox *spinBox = new QDoubleSpinBox( parent ); - spinBox->setRange( -90.0, 90.0 ); - spinBox->setSingleStep( 5.0 ); - spinBox->setDecimals( 3 ); - return spinBox; - } - else if( index.column() == 4 ) { - QDoubleSpinBox *spinBox = new QDoubleSpinBox( parent ); - spinBox->setRange( -180.0, 180.0 ); - spinBox->setSingleStep( 5.0 ); - spinBox->setDecimals( 3 ); - return spinBox; - } - else if( index.column() == 5 ) { - QDoubleSpinBox *spinBox = new QDoubleSpinBox( parent ); - spinBox->setRange( 0.0, 5000.0 ); - spinBox->setSingleStep( 1.0 ); - spinBox->setDecimals( 3 ); - return spinBox; - } - else if( index.column() == 6 ) { - QComboBox *comboBox = new QComboBox( parent ); - comboBox->addItem( "meters" ); - comboBox->addItem( "feet" ); - return comboBox; - } - else if( index.column() == 7 ) { - QDoubleSpinBox *spinBox = new QDoubleSpinBox( parent ); - spinBox->setRange( 0.0, 500.0 ); - spinBox->setSingleStep( 1.0 ); - spinBox->setDecimals( 3 ); - return spinBox; - } - else if( index.column() == 8 ) { - QComboBox *comboBox = new QComboBox( parent ); - comboBox->addItem( "mph" ); - comboBox->addItem( "kph" ); - comboBox->addItem( "mps" ); - comboBox->addItem( "kts" ); - return comboBox; - } - else if( index.column() == 9 ) { - QDoubleSpinBox *spinBox = new QDoubleSpinBox( parent ); - spinBox->setRange( 0.0, 500.0 ); - spinBox->setSingleStep( 1.0 ); - spinBox->setDecimals( 3 ); - spinBox->setSuffix( "\x00B0" ); - return spinBox; - } - else if( index.column() == 10 ) { - QDoubleSpinBox *spinBox = new QDoubleSpinBox( parent ); - spinBox->setRange( 0.0, 150.0 ); - spinBox->setSingleStep( 5.0 ); - spinBox->setSuffix( "\x00B0" ); - spinBox->setDecimals( 3 ); - return spinBox; - } - else if( index.column() == 11 ) { - QComboBox *comboBox = new QComboBox( parent ); - comboBox->addItem( "F" ); - comboBox->addItem( "C" ); - comboBox->addItem( "K" ); - return comboBox; - } - else if( index.column() == 12 ) { - QSpinBox *spinBox = new QSpinBox( parent ); - spinBox->setRange( 0, 100 ); - spinBox->setSingleStep( 5 ); - return spinBox; - } - else if( index.column() == 13 ) { - QDoubleSpinBox *spinBox = new QDoubleSpinBox( parent ); - spinBox->setRange( 0.0, 50000.0 ); - spinBox->setSingleStep( 50.0 ); - return spinBox; - } - else if( index.column() == 14 ) { - QComboBox *comboBox = new QComboBox( parent ); - comboBox->addItem( "miles" ); - comboBox->addItem( "feet" ); - comboBox->addItem( "meters" ); - comboBox->addItem( "km" ); - return comboBox; - } - else - return QItemDelegate::createEditor( parent, option, index ); -} - -/** - * Set the editor data on click - * @param editor the widget to populate - * @param index row and column - */ -void pointInputDelegate::setEditorData( QWidget *editor, - const QModelIndex &index ) const -{ - int column = index.column(); - if( column == 1 ) { - QComboBox *comboBox = qobject_cast( editor ); - QString cs = index.model()->data( index, Qt::DisplayRole ).toString(); - if( cs == "PROJCS" ) - comboBox->setCurrentIndex( 0 ); - else if( cs == "GEOGCS" ) - comboBox->setCurrentIndex( 1 ); - } - else if( column == 2 ) { - QComboBox *comboBox = qobject_cast( editor ); - QString d = index.model()->data( index, Qt::DisplayRole ).toString(); - if( d == "WGS84" ) - comboBox->setCurrentIndex( 0 ); - else if( d == "NAD83" ) - comboBox->setCurrentIndex( 1 ); - else if( d == "NAD27" ) - comboBox->setCurrentIndex( 2 ); - } - else if( column == 6 || column == 8 || - column == 11 || column == 15 ) { - QComboBox *comboBox = qobject_cast( editor ); - QString s = index.model()->data( index, Qt::DisplayRole ).toString(); - comboBox->setEditText( s ); - } - else if( column == 3 || column == 4 || column == 5 || column == 7 || - column == 9 || column == 10 || column == 12 || column == 13 ) { - QDoubleSpinBox *spinBox = qobject_cast( editor ); - double v = index.model()->data( index, Qt::DisplayRole ).toDouble(); - spinBox->setValue( v ); - } - else - return QItemDelegate::setEditorData( editor, index ); -} - -/** - * Use the editor data to update the model behind the controller - * @param editor widget to collect data from - * @param model model associated with the controller - * @param index row and column information - */ -void pointInputDelegate::setModelData( QWidget *editor, - QAbstractItemModel *model, - const QModelIndex &index ) const -{ - int col = index.column(); - int row = index.row(); - pointDataModel* pdm = (pointDataModel*)model; - if( col == 1 ) { - QComboBox *comboBox = qobject_cast( editor ); - if( comboBox->currentIndex() == 0 ) - pdm->stations[row].set_coordType( wxStation::PROJCS ); - else if( comboBox->currentIndex() == 1 ) - pdm->stations[row].set_coordType( wxStation::GEOGCS ); - } - else - QItemDelegate::setModelData( editor, model, index ); -} - -/** - * Update the geomety after editing to handle resizing - * @param editor widget information containing data - * @param option style information - * @param index row and column information - */ -void pointInputDelegate::updateEditorGeometry( QWidget *editor, - const QStyleOptionViewItem &option, - const QModelIndex &index ) const -{ - editor->setGeometry( option.rect ); -} diff --git a/src/gui/pointInputDelegate.h b/src/gui/pointInputDelegate.h deleted file mode 100644 index d896d92b4..000000000 --- a/src/gui/pointInputDelegate.h +++ /dev/null @@ -1,65 +0,0 @@ -/****************************************************************************** - * - * $Id$ - * - * Project: WindNinja Qt GUI - * Purpose: Point initialization delegte. - * Author: Kyle Shannon - * - ****************************************************************************** - * - * THIS SOFTWARE WAS DEVELOPED AT THE ROCKY MOUNTAIN RESEARCH STATION (RMRS) - * MISSOULA FIRE SCIENCES LABORATORY BY EMPLOYEES OF THE FEDERAL GOVERNMENT - * IN THE COURSE OF THEIR OFFICIAL DUTIES. PURSUANT TO TITLE 17 SECTION 105 - * OF THE UNITED STATES CODE, THIS SOFTWARE IS NOT SUBJECT TO COPYRIGHT - * PROTECTION AND IS IN THE PUBLIC DOMAIN. RMRS MISSOULA FIRE SCIENCES - * LABORATORY ASSUMES NO RESPONSIBILITY WHATSOEVER FOR ITS USE BY OTHER - * PARTIES, AND MAKES NO GUARANTEES, EXPRESSED OR IMPLIED, ABOUT ITS QUALITY, - * RELIABILITY, OR ANY OTHER CHARACTERISTIC. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - * - *****************************************************************************/ - -#ifndef POINT_INPUT_DELEGATE_H -#define POINT_INPUT_DELEGATE_H - -#include -#include -#include -#include -#include -#include - -#include - -#include "pointDataModel.h" -#include "wxStation.h" -#include "ninjaUnits.h" - -#include - -class pointInputDelegate : public QItemDelegate -{ - Q_OBJECT - - public: - pointInputDelegate( QObject *parent ); - QWidget *createEditor( QWidget *parent, const QStyleOptionViewItem &option, - const QModelIndex &index ) const; - - void setEditorData( QWidget *editor, const QModelIndex &index ) const; - void setModelData( QWidget *editor, QAbstractItemModel *model, - const QModelIndex &index ) const; - - void updateEditorGeometry( QWidget *editor, - const QStyleOptionViewItem &option, - const QModelIndex &index ) const; -}; -#endif /* POINT_INPUT_DELEGATE_H */ diff --git a/src/gui/stationFetchWidget.cpp b/src/gui/stationFetchWidget.cpp index 5b77c5b51..e6150e888 100644 --- a/src/gui/stationFetchWidget.cpp +++ b/src/gui/stationFetchWidget.cpp @@ -27,6 +27,12 @@ * *****************************************************************************/ +/** @file stationFetchWidget.cpp + * + * Fetch stations from the Mesonet API + * + */ + #include "stationFetchWidget.h" //#include @@ -108,7 +114,6 @@ void stationFetchWidget::watchStartTime() { writeToConsole("Start Time is greater than End Time!, reverting..."); CPLDebug("STATION_FETCH","START TIME > END TIME, FIXING END TIME"); -// startEdit->setDateTime(endEdit->dateTime().addSecs(-3600)); endEdit->setDateTime(startEdit->dateTime().addSecs(3600)); } } @@ -152,16 +157,15 @@ void stationFetchWidget::updateFetchProgress() stationFutureWatcher.waitForFinished(); int result = stationFutureWatcher.result(); //Get the result, 1 good, -1 bad - if (result==-1) - { -// stationFetchProgress->setLabelText("An Error Occured, Possibly no Data Exists for request"); + if (result==-1) //Means that we failed to get data, the error_msg should tell the user + { //What happened stationFetchProgress->setLabelText(QString(pointInitialization::error_msg.c_str())); stationFetchProgress->setRange(0,1); stationFetchProgress->setValue(0); stationFetchProgress->setCancelButtonText("Close"); setCursor(Qt::ArrowCursor); } - else if (result==-2) + else if (result==-2) //Special type of error that we catch in the GUI { stationFetchProgress->setLabelText("ERROR: Selected Time Range is greater than 1 year! Input custom API KEY to remove limits"); stationFetchProgress->setRange(0,1); @@ -169,7 +173,7 @@ void stationFetchWidget::updateFetchProgress() stationFetchProgress->setCancelButtonText("Close"); setCursor(Qt::ArrowCursor); } - else + else //IT WORKED! { stationFetchProgress->setRange(0,100); stationFetchProgress->setValue(1); @@ -215,8 +219,15 @@ void stationFetchWidget::executeFetchStation() // stationFutureWatcher.cancel(); //commented for now, probably can be deleted... } - -std::string stationFetchWidget::removeWhiteSpace(std::string str) //Cleans up spaces in text +/** + * @brief stationFetchWidget::removeWhiteSpace + * //Cleans up spaces in text + * if the user types in a station name and then puts a space + * strip it out + * @param str + * @return + */ +std::string stationFetchWidget::removeWhiteSpace(std::string str) { std::string tofind=" "; std::string toreplace=""; @@ -227,7 +238,12 @@ std::string stationFetchWidget::removeWhiteSpace(std::string str) //Cleans up sp } return(str); } - +/** + * @brief stationFetchWidget::demButcher + * get rid of some crap in the dem so that the file name looks nice + * + * @return + */ std::string stationFetchWidget::demButcher()//Cleans up the DEM for use in the downloader { std::string demRaw = demFileName.toStdString(); @@ -315,10 +331,7 @@ int stationFetchWidget::fetchStation() // where they downloaded the times at // This is only necessary for timeseries however, because the other options, such as 1 step/current data //are time naive and require the user to specify a time for what is current. - //These two lines of code are the old way for which files were generated, leaving them in for debugging for now... -// stationPathName=pointInitialization::generatePointDirectory(demFileName.toStdString(),demUse,eTimeList,true); //As we keep working on the GUI, need to get change eTimeList to timeList for timeseries -// pointInitialization::SetRawStationFilename(stationPathName); - + // This means DEM and Current Data 1 step if (terrainPart==0 && timePart==0) { @@ -327,9 +340,6 @@ int stationFetchWidget::fetchStation() bufferUnits=buffUnits->currentText().toStdString(); fetchNow=true; -// cout<text().toDouble()<currentText().toStdString()<isChecked()<>eH; istringstream(EndTime.substr(14,2))>>eMi; - -// cout< timeList; timeList=pointInitialization::getTimeList(sY,sMo,sD,sH,sMi,eY,eMo,eD,eH,eMi, numSteps,tzString.toStdString()); @@ -461,6 +468,17 @@ int stationFetchWidget::fetchStation() } } +/** + * @brief stationFetchWidget::getMetadata + * + * GUI wrapper for metadata fetcher, + * we don't currently use this + * and instead have a config option + * that fetches metadata at runtime + * + * leave this in incase we decide to add in a + * metadata button later + */ void stationFetchWidget::getMetadata() { QString fileName; diff --git a/src/ninja/cli.cpp b/src/ninja/cli.cpp index 15a9e959b..bd3ab87c6 100644 --- a/src/ninja/cli.cpp +++ b/src/ninja/cli.cpp @@ -324,33 +324,28 @@ int windNinjaCLI(int argc, char* argv[]) ("air_temp_units", po::value(), "surface air temperature units (K, C, R, F)") ("uni_cloud_cover", po::value(), "cloud cover") ("cloud_cover_units", po::value(), "cloud cover units (fraction, percent, canopy_category)") -//STATION_FETCH - ("fetch_station", po::value()->default_value(false), "download a station file from an internet server (true/false)") - ("fetch_station_path", po::value(), "path where the downloaded station file will be written") - ("start_year",po::value(),"start year for simulation") - ("start_month",po::value(),"start month for simulation") - ("start_day",po::value(),"start day for simulation") - ("start_hour",po::value(),"start hour for simulation") - ("start_minute",po::value(),"start minute for simulation") - ("end_year",po::value(),"end year for simulation") - ("end_month",po::value(),"end month for simulation") - ("end_day",po::value(),"end day for simulation") - ("end_hour",po::value(),"end hour for simulation") - ("end_minute",po::value(),"end minute for simulation") - ("number_time_steps",po::value(),"number of timesteps for simulation") - ("fetch_metadata",po::value()->default_value(false),"get station metadata for a domain") - ("metadata_filename",po::value(),"filename for metadata") - ("fetch_type",po::value(),"bbox or stid") - ("fetch_current_station_data",po::value()->default_value(false),"true for latest, false for timeseries") - ("station_buffer",po::value()->default_value(0.00)) - ("station_buffer_units",po::value()->default_value("km")) - ("fetch_station_name",po::value(),"list of stations to initialize with") -//STATION_FETCH + ("fetch_station", po::value()->default_value(false), "download a station file from an internet server (Mesonet API) (true/false)") + ("start_year",po::value(),"point initialization: start year for simulation") + ("start_month",po::value(),"point initialization: start month for simulation") + ("start_day",po::value(),"point initialization: start day for simulation") + ("start_hour",po::value(),"point initialization: start hour for simulation") + ("start_minute",po::value(),"point initialization: start minute for simulation") + ("end_year",po::value(),"point initialization: end year for simulation") + ("end_month",po::value(),"point initialization: end month for simulation") + ("end_day",po::value(),"point initialization: end day for simulation") + ("end_hour",po::value(),"point initialization: end hour for simulation") + ("end_minute",po::value(),"point initialization: end minute for simulation") + ("number_time_steps",po::value(),"point initialization: number of timesteps for simulation") + ("fetch_metadata",po::value()->default_value(false),"get weather station metadata for a domain") + ("metadata_filename",po::value(),"filename for weather station metadata") + ("fetch_type",po::value(),"fetch weather station from bounding box (bbox) or by station ID (stid)") + ("fetch_current_station_data",po::value()->default_value(false),"fetch the latest weather station data (true) or fetch a timeseries (false) (true/false)") + ("station_buffer",po::value()->default_value(0.00),"distance around dem to fetch station data") + ("station_buffer_units",po::value()->default_value("km"),"Units of distance around DEM") + ("fetch_station_name",po::value(),"list of stations IDs to fetch") ("wx_station_filename", po::value(), "path/filename of input wx station file") - ("write_wx_station_kml", po::value()->default_value(false), "write a Google Earth kml file for the input wx stations (true, false)") - ("wx_station_kml_filename", po::value(), "filename for the Google Earth kml wx station output file") - ("write_wx_station_csv",po::value()->default_value(false),"write a csv of the interpolated wxdata") - ("wx_station_csv_filename",po::value()) + ("write_wx_station_kml", po::value()->default_value(false), " point initialization: write a Google Earth kml file for the input wx stations (true, false)") + ("write_wx_station_csv",po::value()->default_value(false),"point initialization: write a csv of the interpolated weather data (true,false)") ("input_wind_height", po::value(), "height of input wind speed above the vegetation") ("units_input_wind_height", po::value(), "units of input wind height (ft, m)") ("output_wind_height", po::value()/*->required()*/, "height of output wind speed above the vegetation") @@ -1021,24 +1016,11 @@ int windNinjaCLI(int argc, char* argv[]) std::string stationPathName; wxStation::SetStationFormat(wxStation::newFormat); - if (vm.count("fetch_station_path")) //Inform that old options no longer are used - { -// stationPathName=vm["fetch_station_path"].as(); -// pointInitialization::SetRawStationFilename(stationPathName); - CPLDebug("STATION_FETCH","fetch_station_path has been disabled."); - } -// else -// { -// stationPathName="blank"; -// pointInitialization::SetRawStationFilename(stationPathName); -// } - pointInitialization::setStationBuffer(vm["station_buffer"].as(), vm["station_buffer_units"].as()); //Sets buffer if (vm["fetch_current_station_data"].as()==false) //If they want a time series { -// option_dependency(vm, "fetch_station", "fetch_station_path"); option_dependency(vm, "fetch_station", "start_year"); option_dependency(vm, "fetch_station", "start_month"); option_dependency(vm, "fetch_station", "start_day"); @@ -1498,16 +1480,11 @@ int windNinjaCLI(int argc, char* argv[]) else if(vm["initialization_method"].as() == string("pointInitialization")) { //STATION_FETCH - option_dependency(vm, "output_wind_height", "units_output_wind_height"); -// option_dependency(vm, "write_wx_station_kml", "wx_station_kml_filename"); -// option_dependency(vm, "write_wx_station_csv","wx_station_csv_filename"); //No Longer need to require a filename if(vm["write_wx_station_csv"].as()==true) //If the user wants an interpolated CSV { CPLDebug("STATION_FETCH", "Writing wxStation csv for step #%d", i); -// wxStation::writeStationFile(windsim.getWxStations( i_ ), -// vm["wx_station_csv_filename"].as()); if(vm.count("output_path")){ pointInitialization::writeStationOutFile(windsim.getWxStations(i_), vm["output_path"].as(), @@ -1526,8 +1503,6 @@ int windNinjaCLI(int argc, char* argv[]) if(vm["write_wx_station_kml"].as() == true) //If the user wants a KML of the stations { CPLDebug("STATION_FETCH", "Writing wxStation kml for step #%d", i_); -// wxStation::writeKmlFile(windsim.getWxStations( i_ ), -// vm["wx_station_kml_filename"].as()); if(vm.count("output_path")){ wxStation::writeKmlFile(windsim.getWxStations( i_ ), vm["elevation_file"].as(), diff --git a/src/ninja/pointInitialization.cpp b/src/ninja/pointInitialization.cpp index 4b5bbc76e..ef3cc79cc 100644 --- a/src/ninja/pointInitialization.cpp +++ b/src/ninja/pointInitialization.cpp @@ -30,24 +30,24 @@ #include "pointInitialization.h" -std::string pointInitialization::dtoken = "33e3c8ee12dc499c86de1f2076a9e9d4"; -const std::string pointInitialization::backup_token = "33e3c8ee12dc499c86de1f2076a9e9d4"; -const std::string pointInitialization::dvar = "wind_speed,wind_direction,air_temp," - "solar_radiation,cloud_layer_1_code"; - -const std::string pointInitialization::ndvar = "wind_speed,wind_direction,air_temp," - "solar_radiation,cloud_layer_1_code," - "cloud_layer_2_code,cloud_layer_3_code"; - -const std::string pointInitialization::baseUrl = "http://api.mesowest.net/v2/stations/"; -std::string pointInitialization::rawStationFilename = ""; -double pointInitialization::stationBuffer; -std::vector pointInitialization::stationFiles; -std::string pointInitialization::tzAbbrev; -vector pointInitialization::start_and_stop_times; +std::string pointInitialization::dtoken = "33e3c8ee12dc499c86de1f2076a9e9d4"; //This is the base token for fetching +const std::string pointInitialization::backup_token = "33e3c8ee12dc499c86de1f2076a9e9d4"; //the same token repeated just in case +const std::string pointInitialization::dvar = "wind_speed,wind_direction,air_temp," //variables we want + "solar_radiation,cloud_layer_1_code"; //from the API + +const std::string pointInitialization::ndvar = "wind_speed,wind_direction,air_temp," //variables we + "solar_radiation,cloud_layer_1_code," //want for + "cloud_layer_2_code,cloud_layer_3_code";//Airport stations + +const std::string pointInitialization::baseUrl = "http://api.mesowest.net/v2/stations/"; //API baseurl +std::string pointInitialization::rawStationFilename = ""; //make the station name blank at first +double pointInitialization::stationBuffer; //Buffer +std::vector pointInitialization::stationFiles; //Where the files are stored +std::string pointInitialization::tzAbbrev; //Abbreviation of the time zone +vector pointInitialization::start_and_stop_times; //Storage for the start and stop time as a local obj //Stores the start and stop time in local time from getTimeList so that we can name the files properly -bool pointInitialization::enforce_limits = true; -std::string pointInitialization::error_msg = "An Error Occured, Possibly no Data Exists for request"; +bool pointInitialization::enforce_limits = true; //Enfore limitations on the API ->set to false if the user provides a custom key +std::string pointInitialization::error_msg = "An Error Occured, Possibly no Data Exists for request"; //generic error message //Set to whether or not we enforce the limits of 1 year and buffer range extern boost::local_time::tz_database globalTimeZoneDB; @@ -354,7 +354,7 @@ void pointInitialization::setInitializationGrids(WindNinjaInputs& input) delete[] influenceRadius; influenceRadius = NULL; } -/* +/** @brief * Check to see if the station data is within the range of user desired times * If not, throw a tantrum... */ @@ -364,8 +364,7 @@ bool pointInitialization::validateTimeData(vector > wxSta vector stationStops; vector stationNames; //Just for organization purposes, probably not necessary after initial debugging -// cout< > wxSta std::string pointInitialization::generatePointDirectory(string demFile, string outPath, std::vector timeList,bool latest) { -// genPath = CPLStrdup(CPLGenerateTempFilename( CPLSPrintf("NINJAFOAM_%s", t.c_str()))); -// genPath = CPLStrdup(CPLGenerateTempFilename(dirName.c_str())); std::string subDem; std::string xDem; std::string fullPath; - std::string sTime; - stringstream ss; xDem = demFile.substr(0,demFile.find(".",0)); std::size_t found = xDem.find_last_of("/"); subDem=xDem.substr(found+1); - - //Calcualte timestamp -// boost::posix_time::ptime time = boost::posix_time::second_clock::local_time(); -// boost::posix_time::ptime epoch(boost::gregorian::date(1970,1,1)); -// boost::posix_time::time_duration::sec_type dNew= (time - epoch).total_seconds(); -// ss< stationVect, string basePathName, string demFileName, bool latest) { -// cout<<"WRITE STATION CSV"< stationVect wxStation curVec = stationVect[j]; std::ostringstream xs; xs< stationVect vector pointInitialization::openCSVList(string csvPath) { vector csvList; - FILE *wxStationList = VSIFOpen( csvPath.c_str(), "r" ); - while(1){ + FILE *wxStationList = VSIFOpen( csvPath.c_str(), "r" ); //If we detect that this is a pointer csv + while(1){ //Open it up and check it const char* f = CPLReadLine(wxStationList); -// cout< pointInitialization::openCSVList(string csvPath) */ vector pointInitialization::readWxStations(string demFileName, string timeZone) //This is how we handle the old format now! { - vector tWork; -// cout<wxLoc; - wxLoc.push_back(rawStationFilename); - storeFileNames(wxLoc); + vectorwxLoc; //list of station locations + wxLoc.push_back(rawStationFilename); //add the one file to the list + storeFileNames(wxLoc); //store the file for later - vectorstationLocs; + vectorstationLocs; //get the id for each station stationLocs=fetchWxStationID(); vector > wxVector; vector > wxOrganized; -// for (int i=0;i singleStationData; - singleStationData = readDiskLine(demFileName, rawStationFilename); - wxVector.push_back(singleStationData); -// cout< tempVec; - tempVec.push_back(wxVector[0][i]); - wxOrganized.push_back(tempVec); - } -// cout< readyToGo; - readyToGo=interpolateNull(demFileName,wxOrganized,timeZone); - + singleStationData = readDiskLine(demFileName, rawStationFilename); //Read in the station data as uninterpolated data + wxVector.push_back(singleStationData); //store it in the vector + + for (int i=0;i tempVec; + tempVec.push_back(wxVector[0][i]); + wxOrganized.push_back(tempVec); + } + + vector readyToGo; + readyToGo=interpolateNull(demFileName,wxOrganized,timeZone); //make the data into a weather station without interpolating - - return readyToGo; } /** @@ -760,10 +717,6 @@ vector pointInitialization::readDiskLine(st std::string oErrorString = ""; preInterpolate oStation; std::vector oStations; - preInterpolate work; - std::vector vecwork; - work.stationName="aaaaaaaa"; - vecwork.push_back(work); OGRDataSourceH hDS; hDS = OGROpen( stationLoc.c_str(), FALSE, NULL ); @@ -790,9 +743,6 @@ vector pointInitialization::readDiskLine(st CPLDebug("STATION_FETCH", "Reading csvName: %s", stationLoc.c_str()); - const char* station; - int idx=0; - poLayer->ResetReading(); const char *pszKey; @@ -1178,31 +1128,9 @@ vector pointInitialization::makeWxStation(vector stationNames; vector stationData; -// OGRDataSourceH hDS; -// hDS = OGROpen( rawStationFilename.c_str(), FALSE, NULL ); -// -// OGRLayer *poLayer; -// OGRFeature *poFeature; -// OGRFeatureDefn *poFeatureDefn; -// poLayer = (OGRLayer*)OGR_DS_GetLayer( hDS, 0 ); -// -// std::string oStationName; -// -// OGRLayerH hLayer; -// hLayer=OGR_DS_GetLayer(hDS,0); -// OGR_L_ResetReading(hLayer); -// -// poLayer->ResetReading(); -// while( ( poFeature = poLayer->GetNextFeature() ) != NULL ) -// { -// poFeatureDefn = poLayer->GetLayerDefn(); -// -// // get Station name -// oStationName = poFeature->GetFieldAsString( 0 ); -// stationNames.push_back(oStationName); -// } - stationNames=fetchWxStationID(); - bool final_sanity_check = checkWxStationSize(stationNames); + + stationNames=fetchWxStationID(); //Get the weather station names + bool final_sanity_check = checkWxStationSize(stationNames); //Check to make sure everything is good if(final_sanity_check==false) { @@ -1219,7 +1147,12 @@ vector pointInitialization::makeWxStation(vector pointInitialization::makeWxStation(vector countLimiter; - for (int ei=1;ei<=idxCount.size();ei++) + for (int ei=1;ei<=idxCount.size();ei++) //This appears to do nothing { int rounder=idxCount.size()-ei; int e=std::accumulate(idxCount.begin(),idxCount.end()-rounder,0); @@ -1254,12 +1187,12 @@ vector pointInitialization::makeWxStation(vector >stationDataList; stationDataList=data; //here is where a wxstation is made - for (int i=0;i pointInitialization::makeWxStation(vector > pointInitialization::interp } for (int i = 0; i > pointInitialization::interp * Remember that Negative is future (high) * Positive is past (low) */ -// cout< > pointInitialization::interp //Get Low and High for each data Type //Wind Speed -// cout<<"WIND SPEED"< 113.000) + if(speed_I > 113.000) //this is too fast, probably a bad interpolation { speed_I = speed_L; @@ -1546,12 +1469,11 @@ vector > pointInitialization::interp interpolatedWxData[k][i].direction = dir_I; //Temperature -// cout<<"TEMPERATURE"< 57.0) + if(temp_I > 57.0) //this is very hot, probably a bad interpolation { temp_I = temp_H; if(temp_I > 57.0) @@ -1560,14 +1482,13 @@ vector > pointInitialization::interp } if(temp_I > 57.0) { - temp_I = 25; + temp_I = 25; //if something is really bad, just let it be 25degC } } interpolatedWxData[k][i].temperature = temp_I; interpolatedWxData[k][i].tempUnits = vecStations[k][0].tempUnits; //Cloud Cover -// cout<<"CLOUD COVER"< pointInitialization::UnifyTime(vector timeList) { vector buildTimes; - vector work; - work.push_back("0"); stringstream startstream; stringstream endstream; boost::posix_time::time_facet *facet = new boost::posix_time::time_facet("%Y%m%d%H%M"); - boost::posix_time::time_duration buffer(1, 0, 0, 0); + boost::posix_time::time_duration buffer(1, 0, 0, 0); //add a 1 hour pad to each side startstream.imbue(locale(startstream.getloc(), facet)); timeList[0] = timeList[0] - buffer; @@ -2291,14 +2213,6 @@ vector pointInitialization::CompareClouds(vectorlow, v vector totalCloudcat; std::string aa; -// cout<=max_download_time)//Sanity Check on requested Time Download { - // throw std::runtime_error("Cannot download more than 1 year worth of data at one time!"); return -2; } else @@ -2963,6 +2876,15 @@ void pointInitialization::setLocalStartAndStopTimes(boost::local_time::local_dat start_and_stop_times.push_back(start); start_and_stop_times.push_back(stop); } +/** + * @brief pointInitialization::writeStationLocationFile + * writes a csv that points to the weather station csvs + * this is needed for CLI runs + * note the comma after the header + * @param stationPath + * @param demFile + * @param current_data + */ void pointInitialization::writeStationLocationFile(string stationPath, std::string demFile, bool current_data){ std::string cName; stringstream statLen; @@ -2982,7 +2904,7 @@ void pointInitialization::writeStationLocationFile(string stationPath, std::stri outFile.open(cName.c_str()); if(current_data==true) { - outFile<<"Recent_Station_File_List,"< - - data/wn-splash.png - images/icons/wn-icon.png - images/icons/wn-desktop.ico - images/icons/resample.png - images/icons/bug_link.png - images/icons/bullet_blue.png - images/icons/jason_bullet_blue.png - images/icons/bullet_error.png - images/icons/cross.png - images/icons/disk.png - images/icons/folder_page.png - images/icons/cog_go.png - images/icons/help.png - images/icons/link.png - images/icons/page_white_acrobat.png - images/icons/tick.png - images/icons/weather_sun.png - images/icons/server_go.png - images/icons/application_get.png - images/icons/cancel.png - images/icons/noaa_bullet.png - images/icons/arrow_rotate_clockwise.png - images/icons/add.png - images/icons/lightning_add.png - images/icons/weather_cloudy.png - images/icons/delete.png - images/icons/jason_caution.png - images/icons/folder.png - images/icons/magnifier.png - images/icons/swoop_final.png - images/icons/center_click_final.png - images/icons/email.png - images/icons/transmit_blue.png - images/icons/transmit.png - images/icons/weather_clouds.png - images/icons/weather_snow.png - images/icons/weather_rain.png - images/icons/weather_lightning.png - images/icons/world.png - + + data/wn-splash.png + images/icons/wn-icon.png + images/icons/wn-desktop.ico + images/icons/resample.png + images/icons/bug_link.png + images/icons/bullet_blue.png + images/icons/jason_bullet_blue.png + images/icons/bullet_error.png + images/icons/cross.png + images/icons/disk.png + images/icons/folder_page.png + images/icons/cog_go.png + images/icons/help.png + images/icons/link.png + images/icons/page_white_acrobat.png + images/icons/tick.png + images/icons/weather_sun.png + images/icons/server_go.png + images/icons/application_get.png + images/icons/cancel.png + images/icons/noaa_bullet.png + images/icons/arrow_rotate_clockwise.png + images/icons/add.png + images/icons/lightning_add.png + images/icons/weather_cloudy.png + images/icons/delete.png + images/icons/jason_caution.png + images/icons/folder.png + images/icons/magnifier.png + images/icons/swoop_final.png + images/icons/center_click_final.png + images/icons/email.png + images/icons/citation.png +