Hello list,
I’m trying to import the 3b42rt TRMM product by using r.in.bin.
I’ve used the follow lines,
r.inr.in.bin --o -f -h input=2001-1-1.bin output=2001-1-1 north=-16 south=-57 east=50 west=76 cols=104 rows=197
but, always i got the follow error message:
ADVERTENCIA: File Size 519968 … Total Bytes 81952
if i don’t use the -h flag, then the error is:
ERROR: Invalid north latitud.
Now i´ḿ guessing my python script to download a .bin file with a subset area is working bad,
this is the script,
from urllib2 import *
from urllib import urlopen
import os
import datetime
init=2001 #start year to download
final=2002 #end year
month_in=1
month_end=5
day_in=1
day_end=31
north="-16" #subset corners
south="-57"
east="-50"
west="-76"
ldirectory="/media/TOSHIBA/trmm_historica/" #destination folder
#Function to conect and download trmm data
def download(url, file_name):
try:
ur = urlopen(url)
contents = ur.readlines()
fo = open(file_name, "w")
print "conected..."
for line in contents:
fo.write(line)
fo.close()
except Exception, e:
print "not possible to conect"
print str(e)
sys.exit(2)
for year in range(init,final):
for month in range(month_in,month_end):
for day in range(day_in,day_end):
url = "[http://disc2.nascom.nasa.gov/daac-bin/Giovanni/tovas/Giovanni_cgi.pl?west=](http://disc2.nascom.nasa.gov/daac-bin/Giovanni/tovas/Giovanni_cgi.pl?west=)"+west+"&north="+north+"&east="+east+"&south="+south+"¶ms=0%7C3B42RT&plot_type=Area+Plot&byr="+str(year)+"&bmo="+str(month)+"&bdy="+str(day)+"&eyr="+str(year)+"&emo="+str(month)+"&edy="+str(day)+"&begin_date=2000%2F03%2F01&end_date="+str(year)+"%2F"+str(month)+"%2F"+str(day)+"&cbar=cdyn&cmin=&cmax=&yaxis=ydyn&ymin=&ymax=&yint=&ascres=0.25x0.25&global_cfg=[tovas.global.cfg.pl](http://tovas.global.cfg.pl)&instance_id=realtime&prod_id=3B42RT_daily&action=ASCII+Output"
print str(year)+"-"+str(month)+"-"+str(day)
download(url, ldirectory+str(year)+"-"+str(month)+"-"+str(day)+".bin")
thanks in advance if somebody can see something that i can´t do it and solve my problem.
if somebody could help me, i´ĺl really appreciate it
–
Diana Marcela Brito Hoyos
Bióloga
"El bosque sería muy triste si solo cantaran los pájaros que mejor lo hacen"
Diana Brito wrote:
I'm trying to import the 3b42rt TRMM product by using r.in.bin.
I've used the follow lines,
r.inr.in.bin --o -f -h input=2001-1-1.bin output=2001-1-1 north=-16
south=-57 east=50 west=76 cols=104 rows=197
but, always i got the follow error message:
ADVERTENCIA: File Size 519968 ... Total Bytes 81952
r.in.bin reads raw binary input. E.g. the above command expects the
file to contain 197*104*4 = 81952 bytes (197 rows by 104 columns by 4
bytes per value).
According to this:
http://www.eol.ucar.edu/projects/name/documentation/3B42RT_README
The original 3B42RT data consists of a 2880-byte header followed by 3
arrays of 480 rows by 1440 columns, the first two being 2 bytes per
value (for a total of 480*1440*2 = 1382400 bytes each) and the third
being 1 byte per value (for a total of 480*1440 = 691200 bytes).
But given the URL you're using:
url = "....prod_id=3B42RT_daily&action=ASCII+Output"
I wouldn't be surprised if the data is being converted to ASCII, in
which case r.in.bin would be entirely the wrong tool to import it.
--
Glynn Clements <glynn@gclements.plus.com>
Thanks for your answer Glynn,
You are totally right, Now i know my script is downloading an ascii file instead a binary file, thats the reason why r.in.bin doesn´t work,
i´m sorry, I didn’t realize about that before.
thanks!!!
···
2015-05-08 0:45 GMT-03:00 Glynn Clements <glynn@gclements.plus.com>:
Diana Brito wrote:
I’m trying to import the 3b42rt TRMM product by using r.in.bin.
I’ve used the follow lines,
r.inr.in.bin --o -f -h input=2001-1-1.bin output=2001-1-1 north=-16
south=-57 east=50 west=76 cols=104 rows=197
but, always i got the follow error message:
ADVERTENCIA: File Size 519968 … Total Bytes 81952
r.in.bin reads raw binary input. E.g. the above command expects the
file to contain 1971044 = 81952 bytes (197 rows by 104 columns by 4
bytes per value).
According to this:
http://www.eol.ucar.edu/projects/name/documentation/3B42RT_README
The original 3B42RT data consists of a 2880-byte header followed by 3
arrays of 480 rows by 1440 columns, the first two being 2 bytes per
value (for a total of 48014402 = 1382400 bytes each) and the third
being 1 byte per value (for a total of 480*1440 = 691200 bytes).
But given the URL you’re using:
url = “…prod_id=3B42RT_daily&action=ASCII+Output”
I wouldn’t be surprised if the data is being converted to ASCII, in
which case r.in.bin would be entirely the wrong tool to import it.
–
Glynn Clements <glynn@gclements.plus.com>
–
Diana Marcela Brito Hoyos
Bióloga
"El bosque sería muy triste si solo cantaran los pájaros que mejor lo hacen"