Difference between revisions of "How to convert data for Geogrid"

From openwfm
Jump to navigation Jump to search
 
(10 intermediate revisions by 3 users not shown)
Line 5: Line 5:
 
== Get Anaconda3 distribution ==
 
== Get Anaconda3 distribution ==
  
Download and install the Python 3 [https://www.continuum.io/downloads Anaconda Python] distribution for your platform. We recommend an installation into the user's home directory.
+
Download and install the Python 3 [https://www.anaconda.com/products/individual Anaconda Python] distribution for your platform. We recommend an installation into the user's home directory.
wget https://repo.continuum.io/archive/Anaconda3-2019.10-Linux-x86_64.sh
 
chmod +x Anaconda3-2019.10-Linux-x86_64.sh
 
./Anaconda3-2019.10-Linux-x86_64.sh
 
  
Add your environment (~/.custom.csh) the following line
+
== Install environment ==
setenv PROJ_LIB "$HOME/anaconda3/share/proj"
 
or if you are using bash to ~/.profile or ~/.bashrc
 
export PROJ_LIB="$HOME/anaconda3/share/proj"
 
  
== Install environment ==
+
Create the python environment:
  
Create a python environment for gdal compatibility. Shortly this is going to be the environment for wrfxpy installation.
+
<pre>
  conda create -n wrfxpy python=3 gdal netcdf4 pyproj paramiko dill scikit-learn h5py pandas psutil proj4
+
conda update -n base -c defaults conda
  conda activate wrfxpy
+
  conda create -n wrfx python=3 gdal netcdf4 pyproj paramiko dill h5py psutil proj4 pytz flask pandas
  conda install -c conda-forge simplekml pygrib f90nml pyhdf xmltodict basemap
+
  conda activate wrfx
 +
  conda install -c conda-forge simplekml pygrib f90nml pyhdf xmltodict basemap rasterio scipy
 
  pip install MesoPy python-cmr
 
  pip install MesoPy python-cmr
 +
</pre>
  
 
Note that <tt>conda</tt> and <tt>pip</tt> are package managers available in the Anaconda Python distribution.
 
Note that <tt>conda</tt> and <tt>pip</tt> are package managers available in the Anaconda Python distribution.
Line 29: Line 25:
 
Get repository wrfxpy and checkout to convert_geotiff branch. Shortly, it is going to be available in the master branch.
 
Get repository wrfxpy and checkout to convert_geotiff branch. Shortly, it is going to be available in the master branch.
 
  git clone https://github.com/openwfm/wrfxpy
 
  git clone https://github.com/openwfm/wrfxpy
 +
cd wrfxpy
 
  git checkout convert_geotiff
 
  git checkout convert_geotiff
  
Line 49: Line 46:
 
  ./convert_geotiff.sh elevation.tif geo_data ZSF
 
  ./convert_geotiff.sh elevation.tif geo_data ZSF
 
  ./convert_geotiff.sh fuel.tif geo_data NFUEL_CAT
 
  ./convert_geotiff.sh fuel.tif geo_data NFUEL_CAT
  ./convert_geotiff.sh ./fuel.tif ./geo_data NFUEL_CAT -112.8115,-112.1661,39.4820,39.9750
+
  ./convert_geotiff.sh fuel.tif geo_data NFUEL_CAT -112.8115,-112.1661,39.4820,39.9750
  
 
== Results from convert_geotiff.sh ==
 
== Results from convert_geotiff.sh ==
Line 61: Line 58:
 
* '''GEOGRID.TBL:''' A text file with the information to add to GEOGRID.TBL (depends on src/geo/var_wisdom.py, so only copy what you need).
 
* '''GEOGRID.TBL:''' A text file with the information to add to GEOGRID.TBL (depends on src/geo/var_wisdom.py, so only copy what you need).
 
* '''index.json:''' A JSON file with index information for each variable.
 
* '''index.json:''' A JSON file with index information for each variable.
 
 
----
 
 
 
 
See the github repository for [https://github.com/jbeezley/convert_geotiff.git convert_geotiff] for the latest documentation and source code.
 
  
 
[[Category:WRF-Fire]]
 
[[Category:WRF-Fire]]
 
[[Category:Howtos|Convert data for Geogrid]]
 
[[Category:Howtos|Convert data for Geogrid]]
 
[[Category:Data]]
 
[[Category:Data]]

Latest revision as of 01:59, 17 February 2021

Back to the WRF-SFIRE user guide.

This wiki page explains how to transform geotiff files to geogrid using convert_geotiff script in wrfxpy.

Get Anaconda3 distribution

Download and install the Python 3 Anaconda Python distribution for your platform. We recommend an installation into the user's home directory.

Install environment

Create the python environment:

 conda update -n base -c defaults conda
 conda create -n wrfx python=3 gdal netcdf4 pyproj paramiko dill h5py psutil proj4 pytz flask pandas
 conda activate wrfx
 conda install -c conda-forge simplekml pygrib f90nml pyhdf xmltodict basemap rasterio scipy
 pip install MesoPy python-cmr

Note that conda and pip are package managers available in the Anaconda Python distribution.

Get wrfxpy repository

Get repository wrfxpy and checkout to convert_geotiff branch. Shortly, it is going to be available in the master branch.

git clone https://github.com/openwfm/wrfxpy
cd wrfxpy
git checkout convert_geotiff

Run convert_geotiff.sh

Run the code to generate geogrid from geotiff files. Run the following line for each variable to process.

./convert_geotiff.sh geotiff_file geo_data_path wrf_variable_name [bbox]

where:

  • geotiff_file - path to a geotiff file to be converted to geogrid
  • geo_data_path - any path where to save all the variables
  • wrf_variable - WRF variable created on src/geo/var_wisdom.py
  • bbox - optional, bounding box to sample the original geotiff file from, using WGS84 coordinates. Format: min_lon,max_lon,min_lat,max_lat

If you want to know more information and the existing options for wrf_variable, run ./convert_geotiff.sh without inputs

./convert_geotiff.sh

Some examples:

./convert_geotiff.sh elevation.tif geo_data ZSF
./convert_geotiff.sh fuel.tif geo_data NFUEL_CAT
./convert_geotiff.sh fuel.tif geo_data NFUEL_CAT -112.8115,-112.1661,39.4820,39.9750

Results from convert_geotiff.sh

The convert_geotiff.sh script will generate a folder specified by the user by geo_data_path with

  • Variable folders: A folder for each variable previously run (ZSF and NFUEL_CAT folders) containing:
    • a geogrid file of the variable.
    • an index file of the variable.
  • geogrid_tbl.json: A JSON file with all the geogrid information for each variable.
  • GEOGRID.TBL: A text file with the information to add to GEOGRID.TBL (depends on src/geo/var_wisdom.py, so only copy what you need).
  • index.json: A JSON file with index information for each variable.