Skip to content

Commit

Permalink
[1.3.22] 2024-11-01
Browse files Browse the repository at this point in the history
*Context*
- Methods Context::sumPrimitiveSurfaceArea(), Context::calculatePrimitiveDataAreaWeightedMean(), and Context::calculatePrimitiveDataAreaWeightedSum() to check if primitive area is NaN, and if so exclude it from calculations.
- Added parse_int2(), parse_int3, and parse_RGBcolor functions to global.cpp.
- Added open_xml_file() function to global.cpp that opens an XML file and checks for basic validity.
- Added 'Location' type to helios_vector_types.h to store latitude, longitude, and UTC offset.
- Added Context::listTimeseriesVariables() to return a list of all existing timeseries variables.

*Plant Architecture*
- Some updates to soybean model parameters.
- Added methods to query UUIDs and Object IDs for all plants in the model to avoid having to loop over each plant instance.
- Some additional checks were needed to make sure the tube internode object actually exists in the Context, otherwise there could be an out-of-bounds error.
- Removed the Shoot Parameter 'internode_radius_max', as it is not needed anymore after the pipe-model-based internode girth scaling was added.
- Corrected some issues with reading/writing plants using strings or XML. Namely, some parameters like the phyllotactic angle were not being applied correctly across shoots.
- Added PlantArchitecture::getCurrentPytomerParameters() to make it easy to get all the phytomer parameters structures to pass to PlantArchitecture::generatePlantFromString().

*Radiation*
- Split spectral_data/surface_spectral_library.xml into separate files for soil, leaves, bark, and fruit, and added many new species. Credit to Kyle Rizzo for these additions.
- Some default values were set in RadiationModel.cpp while others were set in RadiationModel.h. Everything was moved to be set in the RadiationModel constructor, which is in RadiationModel.cpp.

*Solar Position*
- Default constructor changed to load the location based on the location set in the Context.
- UTC offset variable changed from int to float type.

*Visualizer*
- Visualizer::printWindow() now creates the output directory if it does not already exist.
  • Loading branch information
bnbailey-psl committed Nov 1, 2024
1 parent 4ed9ecd commit a607abb
Show file tree
Hide file tree
Showing 872 changed files with 152,286 additions and 113,098 deletions.
18 changes: 18 additions & 0 deletions core/include/Context.h
Original file line number Diff line number Diff line change
Expand Up @@ -2012,6 +2012,9 @@ class Context{
\sa setTime(), getTime()
*/
helios::Time sim_time;

//! Simulation location (latitude, longitude, UTC offset)
helios::Location sim_location;

//! Random number generation engine
std::minstd_rand0 generator;
Expand Down Expand Up @@ -5660,6 +5663,9 @@ class Context{
*/
bool doesTimeseriesVariableExist( const char* label ) const;

//! List all existing timeseries variables
std::vector<std::string> listTimeseriesVariables() const;

//! Load tabular weather data from text file into timeseries
void loadTabularTimeseriesData( const std::string &data_file, const std::vector<std::string> &column_labels, const std::string &delimiter, const std::string &date_string_format="YYYYMMDD", uint headerlines=0 );

Expand Down Expand Up @@ -6024,6 +6030,18 @@ class Context{
* \sa setTime()
*/
helios::Time getTime() const;

//! Set the location of the simulation (latitude, longitude, and UTC offset)
/**
* \param[in] location Location vector
*/
void setLocation( const helios::Location &location );

//! Get the location of the simulation (latitude, longitude, and UTC offset)
/**
* \return Location vector
*/
helios::Location getLocation() const;

//! Draw a random number from a uniform distribution between 0 and 1
/**
Expand Down
26 changes: 26 additions & 0 deletions core/include/global.h
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,22 @@ namespace helios{
*/
bool parse_int( const std::string &input_string, int &converted_int );

//! Convert a string into an int2 with error checking
/**
* \param[in] input_string String to be converted to numerical value
* \param[out] converted_int2 Output numerical value converted from input string
* \return True if conversion was successful, false if unsuccessful
*/
bool parse_int2( const std::string &input_string, int2 &converted_int2 );

//! Convert a string into an int3 with error checking
/**
* \param[in] input_string String to be converted to numerical value
* \param[out] converted_int3 Output numerical value converted from input string
* \return True if conversion was successful, false if unsuccessful
*/
bool parse_int3( const std::string &input_string, int3 &converted_int3 );

//! Convert a string into an unsigned integer with error checking
/**
* \param[in] input_string String to be converted to numerical value
Expand All @@ -277,6 +293,16 @@ namespace helios{
*/
bool parse_vec3( const std::string &input_string, vec3 &converted_vec3 );

//! Convert a string into an RGBcolor with error checking
/**
* \param[in] input_string String to be converted to numerical value
* \param[out] converted_rgb Output numerical value converted from input string
* \return True if conversion was successful, false if unsuccessful
*/
bool parse_RGBcolor( const std::string &input_string, RGBcolor &converted_rgb );

bool open_xml_file( const std::string &xml_file, pugi::xml_document &xmldoc, std::string &error_string );

//! Parse an XML tag containing an integer value
/**
* \param[in] node XML node containing the tag
Expand Down
63 changes: 63 additions & 0 deletions core/include/helios_vector_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -1463,6 +1463,69 @@ inline bool Time::operator!=( const Time &c ) const{
return c.hour!=hour || c.minute!=minute || c.second!=second;
}

//! Location vector
/**
* \ingroup vectors
*/
struct Location{

//! Latitude in degrees (+northern hemisphere, -southern hemisphere)
float latitude_deg;
//! Longitude in degrees (+western hemisphere, -eastern hemisphere)
float longitude_deg;
//! Offset from UTC in hours (+moving West)
float UTC_offset;

//! Default constructor
Location(){
latitude_deg = 38.55f;
longitude_deg = 121.76f;
UTC_offset = 8;
}

//! latitude/longitude/UTC constructor
/**
* \param[in] hour Hour of day (0-23)
* \param[in] minute Minute of hour (0-59)
*/
Location( float latitude_deg, float longitude_deg, float UTC_offset ){

this->latitude_deg = latitude_deg;
this->longitude_deg = longitude_deg;
this->UTC_offset = UTC_offset;

}

//! check for equality of two locations
bool operator==( const helios::Location &c ) const;
//! check for inequality of two locations
bool operator!=( const helios::Location &c ) const;

//! Write Location to output stream
friend std::ostream &operator<<(std::ostream &os, helios::Location const &t) {
return os << "<" << t.latitude_deg << "," << t.longitude_deg << "," << t.UTC_offset << ">";
}

};

//! Make a Location vector
/**
* \param[in] latitude_deg Latitude in degrees (+northern hemisphere, -southern hemisphere)
* \param[in] longitude_deg Longitude in degrees (+western hemisphere, -eastern hemisphere)
* \param[in] UTC_offset Offset from UTC in hours (+moving West)
* \ingroup vectors
*/
inline Location make_Location( float latitude_deg, float longitude_deg, float UTC_offset ){
return {latitude_deg,longitude_deg,UTC_offset};
}

inline bool Location::operator==( const Location &c ) const{
return c.latitude_deg==latitude_deg && c.longitude_deg==longitude_deg && c.UTC_offset==UTC_offset;
}

inline bool Location::operator!=( const Location &c ) const{
return c.latitude_deg!=latitude_deg || c.longitude_deg!=longitude_deg || c.UTC_offset!=UTC_offset;
}

//! Vector of spherical coordinates (elevation,azimuth)
/**
Expand Down
20 changes: 20 additions & 0 deletions core/src/Context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ Context::Context(){

sim_time = make_Time(12,0);

sim_location = make_Location(38.55, 121.76, 8);

// --- Initialize random number generator ---- //

unsigned seed = std::chrono::system_clock::now().time_since_epoch().count();
Expand Down Expand Up @@ -1165,6 +1167,14 @@ Time Context::getTime() const{
return sim_time;
}

void Context::setLocation( const helios::Location &location ){
sim_location = location;
}

helios::Location Context::getLocation() const{
return sim_location;
}

float Context::randu(){
return unif_distribution(generator);
}
Expand Down Expand Up @@ -2023,6 +2033,16 @@ bool Context::doesTimeseriesVariableExist( const char* label ) const{

}

std::vector<std::string> Context::listTimeseriesVariables() const{
std::vector<std::string> labels;
labels.reserve( timeseries_data.size() );
for( const auto& it : timeseries_data ){
labels.push_back(it.first);
}
return labels;
}


void Context::getDomainBoundingBox( vec2& xbounds, vec2& ybounds, vec2& zbounds ) const{

xbounds.x = 1e8;
Expand Down
Loading

0 comments on commit a607abb

Please sign in to comment.