From d9df95f75b92e585076f352e063d4eeb86e41eb1 Mon Sep 17 00:00:00 2001 From: Manfred Brath Date: Thu, 2 May 2024 15:38:24 +0200 Subject: [PATCH 1/3] Add new WSM to change sun geometry --- src/m_sun.cc | 23 +++++++++++++++++++++++ src/methods.cc | 23 ++++++++++++++++++++++- 2 files changed, 45 insertions(+), 1 deletion(-) diff --git a/src/m_sun.cc b/src/m_sun.cc index ba6e9aa86f..fd49f9393d 100644 --- a/src/m_sun.cc +++ b/src/m_sun.cc @@ -190,6 +190,29 @@ void sunsAddSingleFromGridAtLocation( } +void sunsChangeGeometry(ArrayOfSun &suns, + // Inputs: + const Numeric &radius, + const Numeric &distance, + const Numeric &latitude, + const Numeric &longitude, + const Index &sun_index, + const Verbosity &) +{ + + if (radius > 0) suns[sun_index].radius=radius; + if (distance > 0) suns[sun_index].distance=distance; + + //some sanity checks + ARTS_USER_ERROR_IF (distance -999) suns[sun_index].latitude=latitude; + if (longitude > -999) suns[sun_index].latitude=longitude; +} + + void sunsOff(Index &suns_do, ArrayOfSun &suns, const Verbosity &){ diff --git a/src/methods.cc b/src/methods.cc index 7db87c2b34..91a7b87130 100644 --- a/src/methods.cc +++ b/src/methods.cc @@ -19770,7 +19770,28 @@ where N>=0 and the species name is something line "H2O". "The description of the sun. ", "The latitude of the sun spectrum measurement. ", "The longitude of the sun spectrum measurement. ", - "The altitude of the sun spectrum measurement. "))); + "The altitude of the sun spectrum measurement. "))); + + md_data_raw.push_back(create_mdrecord( + NAME("sunsChangeGeometry"), + DESCRIPTION( + "Change the geometry of desired sun\n"), + AUTHORS("Manfred Brath"), + OUT("suns"), + GOUT(), + GOUT_TYPE(), + GOUT_DESC(), + IN(), + GIN("radius","distance","latitude","longitude","index"), + GIN_TYPE("Numeric","Numeric","Numeric","Numeric","Index"), + GIN_DEFAULT("-999","-999","-999","-999",NODEF), + GIN_DESC("The radius of the sun in meter. " + "Default is the radius of our Sun. ", + "The distance between the location and the " + "center of the sun in meter.", + "The latitude or the zenith position of the sun in the sky.", + "The longitude or azimuthal position of the sun in the sky.", + "The index of the sun to change."))); md_data_raw.push_back(create_mdrecord( NAME("sunsOff"), From 5bcc59b4a31e28d57d287833273204f2d7f7c9b3 Mon Sep 17 00:00:00 2001 From: Manfred Brath Date: Mon, 13 May 2024 10:20:21 +0200 Subject: [PATCH 2/3] Add bugfix --- src/m_sun.cc | 4 +++- src/methods.cc | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/m_sun.cc b/src/m_sun.cc index fd49f9393d..bc9f44890e 100644 --- a/src/m_sun.cc +++ b/src/m_sun.cc @@ -192,6 +192,7 @@ void sunsAddSingleFromGridAtLocation( void sunsChangeGeometry(ArrayOfSun &suns, // Inputs: + const Index &suns_do, const Numeric &radius, const Numeric &distance, const Numeric &latitude, @@ -199,6 +200,7 @@ void sunsChangeGeometry(ArrayOfSun &suns, const Index &sun_index, const Verbosity &) { + if (suns_do == 0) return; if (radius > 0) suns[sun_index].radius=radius; if (distance > 0) suns[sun_index].distance=distance; @@ -209,7 +211,7 @@ void sunsChangeGeometry(ArrayOfSun &suns, " is smaller than the radius of the sun (", radius," m )") if (latitude > -999) suns[sun_index].latitude=latitude; - if (longitude > -999) suns[sun_index].latitude=longitude; + if (longitude > -999) suns[sun_index].longitude=longitude; } diff --git a/src/methods.cc b/src/methods.cc index 91a7b87130..5d90856eaa 100644 --- a/src/methods.cc +++ b/src/methods.cc @@ -19781,7 +19781,7 @@ where N>=0 and the species name is something line "H2O". GOUT(), GOUT_TYPE(), GOUT_DESC(), - IN(), + IN("suns_do"), GIN("radius","distance","latitude","longitude","index"), GIN_TYPE("Numeric","Numeric","Numeric","Numeric","Index"), GIN_DEFAULT("-999","-999","-999","-999",NODEF), From 681415ac23bab422b68616a03de3246c768bb696 Mon Sep 17 00:00:00 2001 From: Manfred Brath Date: Mon, 3 Jun 2024 14:38:08 +0200 Subject: [PATCH 3/3] Redesign WSM * Add additional checks * Update and bug fix documentation * Format code --- src/m_sun.cc | 45 ++++++++++++++++++++++++++++----------------- src/methods.cc | 19 ++++++++++--------- 2 files changed, 38 insertions(+), 26 deletions(-) diff --git a/src/m_sun.cc b/src/m_sun.cc index bc9f44890e..2c23bcaf7d 100644 --- a/src/m_sun.cc +++ b/src/m_sun.cc @@ -191,29 +191,40 @@ void sunsAddSingleFromGridAtLocation( } void sunsChangeGeometry(ArrayOfSun &suns, - // Inputs: - const Index &suns_do, - const Numeric &radius, - const Numeric &distance, - const Numeric &latitude, - const Numeric &longitude, - const Index &sun_index, - const Verbosity &) + // Inputs: + const Numeric &radius, + const Numeric &distance, + const Numeric &latitude, + const Numeric &longitude, + const Index &sun_index, + const Verbosity &) { - if (suns_do == 0) return; + if (sun_index == -999) return; + + ARTS_USER_ERROR_IF(sun_index+1 > suns.nelem(), + "The sun index ", sun_index, " is out of range. \n" + "The sun array has only ", suns.nelem(), " elements.") - if (radius > 0) suns[sun_index].radius=radius; - if (distance > 0) suns[sun_index].distance=distance; + if (radius > 0) suns[sun_index].radius = radius; + if (distance > 0) suns[sun_index].distance = distance; //some sanity checks - ARTS_USER_ERROR_IF (distance -999) suns[sun_index].latitude=latitude; - if (longitude > -999) suns[sun_index].longitude=longitude; -} + ARTS_USER_ERROR_IF(latitude < -90 || latitude > 90, + "The latitude of the sun should be between -90 and 90 degrees,\n" + "but is ", latitude, " degrees") + ARTS_USER_ERROR_IF(longitude < -180 || longitude > 360, + "The longitude of the sun should be between -180 and 360 degrees,\n" + "but is ", longitude, " degrees") + + + suns[sun_index].latitude = latitude; + suns[sun_index].longitude = longitude; +} void sunsOff(Index &suns_do, ArrayOfSun &suns, diff --git a/src/methods.cc b/src/methods.cc index 5d90856eaa..2f3eb6bbc1 100644 --- a/src/methods.cc +++ b/src/methods.cc @@ -19781,17 +19781,18 @@ where N>=0 and the species name is something line "H2O". GOUT(), GOUT_TYPE(), GOUT_DESC(), - IN("suns_do"), + IN(), GIN("radius","distance","latitude","longitude","index"), GIN_TYPE("Numeric","Numeric","Numeric","Numeric","Index"), - GIN_DEFAULT("-999","-999","-999","-999",NODEF), - GIN_DESC("The radius of the sun in meter. " - "Default is the radius of our Sun. ", - "The distance between the location and the " - "center of the sun in meter.", - "The latitude or the zenith position of the sun in the sky.", - "The longitude or azimuthal position of the sun in the sky.", - "The index of the sun to change."))); + GIN_DEFAULT("-999","-999","-999","-999","-999"), + GIN_DESC("The radius of the sun in meter. If set to -999, it is not changed", + "Distance from center of the planet to center of the sun in meter." + "If set to -999, it is not changed", + "Latitude of the zenith position of the sun. Must be between -90 and 90." + "If set to -999, it is not changed", + "Longitude of the zenith position of the sun. Must be between -180 and 360." + "If set to -999, it is not changed", + "The index of the sun to change. If set to -999 nothing is changed"))); md_data_raw.push_back(create_mdrecord( NAME("sunsOff"),