alexander-petkov / wfas

A placeholder for the WFAS project.
4 stars 1 forks source link

Solar Radiation calculations fro RTMA and NDFD #22

Open alexander-petkov opened 4 years ago

alexander-petkov commented 4 years ago

Calculate the surface solar radiation grid for each hour of the RTMA and NDFD periods and pipeline it into the list of coverages for these archives.

Use the code from WindNinja as a guide: https://github.com/firelab/windninja/blob/master/src/solar_grid/solar_grid.cpp

alexander-petkov commented 4 years ago

Solar radiation output from an RTMA Cloud Cover file and an elevation file clipped and resampled to RTMA extent and resolution:

Screenshot from 2020-03-11 14-04-22

Edit: It looks like I have to find a DEM file covering the full RTMA extent, not just CONUS

Edit 2: Replaced the screenshot with solar computations using SRTM30 elevation data, reprojected, resampled and clipped to RTMA values.

alexander-petkov commented 4 years ago

How to compile the solar_grid executable

  1. Grab the windninja source from Github:
    git clone https://github.com/firelab/windninja.git
  2. Install GDAL and boost libraries (example is for Ubuntu):
    sudo apt install libboost-all-dev
    sudo apt install libgdal-dev
  3. Compile the following cpp files in the src/ninja directory:
g++ -c  -Wall -g Elevation.cpp -I /usr/include/gdal -l gdal
g++ -c  -Wall -g Aspect.cpp -I /usr/include/gdal -l gdal
g++ -c  -Wall -g Slope.cpp -I /usr/include/gdal -l gdal
g++ -c  -Wall -g Shade.cpp -I /usr/include/gdal -l gdal
g++ -c  -Wall -g Solar.cpp -I /usr/include/gdal -l gdal
g++ -c  -Wall -g solpos.cpp -I /usr/include/gdal -l gdal
g++ -c  -Wall -g ninja_init.cpp -I /usr/include/gdal -l gdal
g++ -c  -Wall -g ninja_conv.cpp -I /usr/include/gdal -l gdal
  1. From within the src/solar_grid directory, compile the solar_grid executable:
g++ -g -o solar_grid solar_grid.cpp  \
       -I /usr/include/gdal/ -I /usr/include -I ../ninja \ 
       -l gdal -l boost_date_time \
       ../ninja/Elevation.o ../ninja/Shade.o ../ninja/Aspect.o ../ninja/Slope.o \ 
      ../ninja/solar.o ../ninja/ninja_init.o ../ninja/solpos.o ../ninja/ninja_conv.o
alexander-petkov commented 4 years ago

Computing solar radiation files.

The following steps are for the RTMA files.

  1. Prepare elevation raster with same projection, extent, and resolution as RTMA files

    gdalwarp -t_srs '+proj=lcc +lat_1=25 +lat_2=25 +lat_0=25 +lon_0=-95 +x_0=0 +y_0=0 +a=6371200 +b=6371200 +units=m +no_defs' -s_srs '+proj=aea +lat_1=29.5 +lat_2=45.5 +lat_0=23 +lon_0=-96 +x_0=0 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs' -te -3272417.140 -265067.354 2683186.395, 3790838.337 -tr 2539.702999999999975 2539.702999999999975 -of GTiff ~/Downloads/cephfs/wfas/data/rtma/varanl/tif/2t/rtma2p5.20190911/rtma2p5.t00z.2dvaranl_ndfd.grb2_wexp ~/Downloads/cephfs/wfas/data/rtma/rtma_dem.tif
  2. Copy timezone file to the same directory as the new executable:

    cp ../data/date_time_zonespec.csv .
  3. Run the solar_grid executable:

    ./solar_grid --cloud-file ~/Downloads/cephfs/wfas/data/rtma/varanl/tif/tcc/rtma2p5.20190911/rtma2p5.t00z.2dvaranl_ndfd.grb2_wexp \ 
    --minute 0 --hour 0 --day 11 --month 9 --year 2019 --time-zone UTC \
    ~/Downloads/cephfs/wfas/data/rtma/rtma_dem.tif solar.tif
alexander-petkov commented 4 years ago

Compile a static executable, which is capable of running multiple threads:

  1. I downloaded GDAL and compiled a stripped down version on a VM instance:
    wget http://download.osgeo.org/gdal/2.4.0/gdal-2.4.0.tar.gz
    tar xzvf gdal-2.4.0.tar.gz 
    cd gdal-2.4.0/
    sudo apt install libproj-dev
    ./configure --without-libtool --without-libz --with-grib=no --with-mrf=no --with-expat=no --with-xml2=no --with-lerc=no --with-jpeg=internal --with-crypto=no --with-proj=yes --enable-shared=no
  2. Compile a multiple-threads capable, static executable with the * -static and -fopenmp flags;
    g++ -g --static -std=c++11 -fopenmp -o solar_grid solar_grid.cpp -I ../ninja -I /home/ubuntu/gdal-2.4.0/gcore/ -I /home/ubuntu/gdal-2.4.0/port -I /home/ubuntu/gdal-2.4.0/ogr/ -I /home/ubuntu/gdal-2.4.0/alg -L /home/ubuntu/gdal-2.4.0/ -l gdal -l boost_date_time -l pthread -l proj -l z -l dl -l tiff -l geotiff -l lzma -l jbig  ../ninja/Elevation.o ../ninja/Shade.o ../ninja/Aspect.o ../ninja/Slope.o ../ninja/solar.o ../ninja/ninja_init.o ../ninja/solpos.o ../ninja/ninja_conv.o
alexander-petkov commented 4 years ago

Attached is animated output for Solar radiation computed with RTMA Cloud Cover data.

I am not sure that the values are what is expected--I simply used the Cloud Cover rasters as inputs.

rtma-Solar_radiation

Animation request (on I2): http://192.168.59.56:8081/geoserver/wms?request=animate&aparam=TIME&avalues=2020-03-09T00:00:00.000Z,2020-03-09T01:00:00.000Z,2020-03-09T02:00:00.000Z,2020-03-09T03:00:00.000Z,2020-03-09T04:00:00.000Z,2020-03-09T05:00:00.000Z,2020-03-09T06:00:00.000Z,2020-03-09T07:00:00.000Z,2020-03-09T08:00:00.000Z,2020-03-09T09:00:00.000Z,2020-03-09T10:00:00.000Z,2020-03-09T11:00:00.000Z,2020-03-09T12:00:00.000Z,2020-03-09T13:00:00.000Z,2020-03-09T14:00:00.000Z,2020-03-09T15:00:00.000Z,2020-03-09T16:00:00.000Z,2020-03-09T17:00:00.000Z,2020-03-09T18:00:00.000Z,2020-03-09T19:00:00.000Z,2020-03-09T20:00:00.000Z,2020-03-09T21:00:00.000Z,2020-03-09T22:00:00.000Z,2020-03-09T23:00:00.000Z&layers=rtma%3ASolar_radiation&bbox=-3272417.14%2C-265067.354%2C2683186.395%2C3790838.337&width=768&height=523&srs=EPSG%3A45558&image/gif;subtype=animated

alexander-petkov commented 4 years ago

Solar radiation is configured for RTMA, NDFD, and GFS dataset in Geoserver, and as part of the update chain for each dataset commit

I am not sure of accuracy and usefulness for Solar radiation from GFS data, considering that the inputs are such a coarse resolution: gfs-Solar_radiation

alexander-petkov commented 4 years ago

The static executable is working on the AWS instances as well, just by copying and running it.