Scheduled Downtime
On Friday 21 April 2023 @ 5pm MT, this website will be down for maintenance and expected to return online the morning of 24 April 2023 at the latest

New "greenfrac_fpar" tiff for binary WRF

laurizio

New member
Hello everybody!

I created a new climatology for "greenfrac_fpar" based on GLASS_MODIS products in tiff format, one file for each month.

I merged the files into one file with separate bands in QGIS in tiff format.

But when I went to convert the new file using this link: GitHub - openwfm/convert_geotiff: A commandline utility for converting GeoTIFF files for use in WRF it gave an error (I used this link to convert the Land Cover and everything went well).

Can anyone tell me how do I merge the files into one and do this conversion so that the files are read by WRF?
 
Not yet, I'm thinking as a possible solution to convert each file into binary separately.
And then using some other program to join the files.
But I haven't tested it yet. If I can do that, I'll follow the procedure here.
But I'm still a beginner in WRF and programming.
 
Check this other thread: Combine multiple geogrid binary files into one

I am trying to replicate that to see if it works. And like you said, create a binary file for each month. My issue now is how to use the "cat" to combine all the months for all the files created using the convert_geotiff program. Hopefully, linux may offer a way out. Currently surfing the net to get some answers.
 
Hi, I have been successful now. These are the steps I followed:

1. Converted each monthly greenfrac.nc file to tiff.

2. Created a parent directory called greenfrac_binaries.

3. In greenfrac_binaries directory, I created subfolders named a, b, c ... (these names imply Jan, Feb, Mar), hence up to alphabet "l" for the 12 months.

4. Converted each file tiff file into binary wps format using the "convert_geotiff" command and saved into the respective files (Since it is the same domain, the same file names will be given for the binaries, so it's advisable to perform this conversion in the respective monthly folders to avoid over-writing).

5. Created a list of the binary file names in folder "a" and saved to a file called list.txt. (ls > list.txt, see sample attached)

6. The next step was to merge the binary files, such that, each folder from b-l (aka Feb-Dec) are appended to each of the corresponding files in folder a (aka Jan). Find my bash script for this merging attached. It would be useful to delete the index files in all folders except "a", else the content of the index files in b-l would also be appended to that of the index file in "a". Also make sure the list.txt is in the same folder as the merge script, or you show the path in the script if it isn't.

7. After running the script (bash merge_binary_script.sh) at command prompt, the merged binaries were saved in the parent folder (as I ran in this folder).

8. Finally, added this "tile_z = 12", to the index file. You can check a sample of the merged binary file size to know if it is approximately equal to what you expect after multiplying by 12.

PS: I did everything in Linux. Hopefully, you are working with a Unix based system. I have no idea how the merge script would run in a windows command prompt.

I have also performed a WRF run with the new greenfrac binaries, and it was successful. I visualized the geo_em_d01.nc file after the simulation, and the monthly greenfrac is the same as that in the monthly tiff files.

Please rename the merge_binary_script.txt below to merge_binary_script.sh before using it. Had to use the extension ".txt" to make it compatible to upload, including that of the attached index.

***Also note that, because the folders are in alphabetical order, the "cat" command in the script would append alphabetically (which is what we want as in actual sense, they are Jan (a), Feb (b) etc. If you use directory names as Jan, Feb, etc., the merging will probably start from April etc because it will be the first one sorted by default in ascending order in the directory. "cat" appends according to the default file or directory order in a directory. It is not arbitrary.***

Hope this helps
 

Attachments

  • merge_binary_script.txt
    202 bytes · Views: 22
  • list.txt
    125.9 KB · Views: 15
  • index.txt
    375 bytes · Views: 13
Last edited:
Hi!

I did the same procedure, but it's giving an error when reading the greenfrac "geo_em.d01.nc".

Attached is the index and a file.

obs.: remove the 'txt' extension from the file 07101-07200.03501-03600.txt -> 07101-07200.03501-03600
 

Attachments

  • index.txt
    352 bytes · Views: 5
  • 07101-07200.03501-03600.txt
    263.3 KB · Views: 3
Hi Laurizio, is this the only binary file that was created, or there are others, as I perceive your data may be global?
 
Exactly the data is global. This is just one of the quadrants. I tried to open this file with a python script (leitor_greenmodis.py) that opened the default greenfrac_modis, but it does not open the files, it gives an error.

convert leitor_geenfracmodis.txt -> leitor_geenfracmodis.py
 

Attachments

  • leitor_greenmodis.txt
    232 bytes · Views: 6
I am not an expert, but I would recommend you start with a clipped tiff of your study region instead of using the global.
 
Top