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

Feature #2966 local_solar_time #3008

Merged
merged 16 commits into from
Nov 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
2c13fda
Per #2966, add new solar_time() function to the vx_solar library.
JohnHalleyGotway Nov 4, 2024
4b469d6
Per #2966, add support for new solar_time masking type. Also make log…
JohnHalleyGotway Nov 4, 2024
2328400
Per #2966, add a units attribute to the output NetCDF mask variable.
JohnHalleyGotway Nov 4, 2024
ea9840d
Per #2966, modify solar azimuth and altitude strings to make the log …
JohnHalleyGotway Nov 4, 2024
0ed3fe2
Per #2966, add gen_vx_mask unit test to demonstrate the solar_time ma…
JohnHalleyGotway Nov 4, 2024
2a32e45
Per #2966, add documentation about the -solar_time option
JohnHalleyGotway Nov 4, 2024
8734801
Per #2966, reduce SonarQube code smells in gen_vx_mask
JohnHalleyGotway Nov 5, 2024
e865e98
Per #2966, reduce SonarQube findings
JohnHalleyGotway Nov 5, 2024
a64930f
Per #2966, support multiple mask types with the same mask field being…
JohnHalleyGotway Nov 5, 2024
42ff3cf
Per #2966, add UTC
JohnHalleyGotway Nov 5, 2024
b1268a8
Per #2966, update gen_vx_mask docs about supporting multiple -type op…
JohnHalleyGotway Nov 5, 2024
4ff2c26
Per #2966, update logic to fix using data masking twice, add a unit t…
JohnHalleyGotway Nov 6, 2024
120d132
Merge branch 'feature_2966_local_solar_time' of https://github.com/dt…
JohnHalleyGotway Nov 6, 2024
0177be5
Per #2966, adjust the logic slightly to revert to existing behavior w…
JohnHalleyGotway Nov 6, 2024
f016f5d
Per #2966, update details about the -union, -intersection, and -symdi…
Nov 22, 2024
350e1d9
Merge remote-tracking branch 'origin/develop' into feature_2966_local…
Nov 22, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
130 changes: 83 additions & 47 deletions docs/Users_Guide/masking.rst

Large diffs are not rendered by default.

42 changes: 42 additions & 0 deletions internal/test_unit/xml/unit_gen_vx_mask.xml
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,27 @@
</output>
</test>

<!-- -->
<!-- SOLAR_TIME: Solar time -->
<!-- -->

<test name="gen_vx_mask_SOLAR_TIME">
<exec>&MET_BIN;/gen_vx_mask</exec>
<param> \
'G004' \
'20050808_12' \
&OUTPUT_DIR;/gen_vx_mask/SOLAR_MIDNIGHT_NH.nc \
-type solar_time,solar_alt,lat \
-thresh 'ge21||le3,le0,ge0' \
-intersection \
-name SOLAR_MIDNIGHT_NH \
-v 3
</param>
<output>
<grid_nc>&OUTPUT_DIR;/gen_vx_mask/SOLAR_MIDNIGHT_NH.nc</grid_nc>
</output>
</test>

<!-- -->
<!-- LAT: latitude band -->
<!-- -->
Expand Down Expand Up @@ -472,6 +493,27 @@
</output>
</test>

<!-- -->
<!-- DATA/DATA/LAT/LON: freezing western hemisphere land points -->
<!-- -->

<test name="gen_vx_mask_DATA_DATA_LAT_LON">
<exec>&MET_BIN;/gen_vx_mask</exec>
<param> \
&DATA_DIR_MODEL;/grib2/gfs/gfs_2012040900_F012.grib2 \
&DATA_DIR_MODEL;/grib2/gfs/gfs_2012040900_F012.grib2 \
&OUTPUT_DIR;/gen_vx_mask/DATA_DATA_LAT_LON_mask.nc \
-type data,data,lat,lon \
-mask_field 'name="LAND"; level="L0";' \
-mask_field 'name="TMP"; level="L0";' \
-thresh eq1,lt273,gt0,lt0 \
-intersection -v 5
</param>
<output>
<grid_nc>&OUTPUT_DIR;/gen_vx_mask/DATA_DATA_LAT_LON_mask.nc</grid_nc>
</output>
</test>

<!-- -->
<!-- SHAPE: shapefile masking -->
<!-- -->
Expand Down
43 changes: 43 additions & 0 deletions src/libcode/vx_solar/solar.cc
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,49 @@ return;
////////////////////////////////////////////////////////////////////////


double solar_time(unixtime gmt, double lon)

{

//
// right ascension and declination
//

double Ra;
double Dec;

solar_radec(gmt, Ra, Dec);

//
// local hour angle
//

double lha = gmt_to_gmst(gmt) - lon - Ra;

//
// rescale angle to -180 to 180
//

lha -= 360.0*floor((lha + 180.0)/360.0);

//
// rescale local hour angle to decimal hours of the solar day
//

double solar_hr = (lha + 180.0)/360.0 * 24;

//
// done
//

return solar_hr;

}


////////////////////////////////////////////////////////////////////////


void dh_to_aa(double lat, double Dec, double lha, double & alt, double & azi)

{
Expand Down
19 changes: 19 additions & 0 deletions src/libcode/vx_solar/solar.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,25 @@ extern void solar_altaz(unixtime gmt, double lat, double lon, double & alt, doub
////////////////////////////////////////////////////////////////////////


extern double solar_time(unixtime gmt, double lon);

//
// calculates the solar time for the given longitude.
//
//
// Input: gmt, greenwich mean time expressed as unix time
//
// lon, longitude (degrees) of given location (+ west, - east)
//
//
// Output: decimal hours f the solar day in range [0, 24),
// where 12 is solar noon
//


////////////////////////////////////////////////////////////////////////


extern void solar_radec(unixtime gmt, double & Ra, double & Dec);

//
Expand Down
Loading
Loading