Hey Jeff,

I've got it sorted out a bit now. You're right the data was an output from
Degrib and I had the option to output the csv's with or without data in the
land areas. As before I was using a program that was placing the pixels in
an image based on the X and Y columns it didn't create an issue. That was an
easy fix by switching the option in the Degrib export.

Also by looking at your example I realized the way the contourf function
requests the Z data and by just reshaping the array I was able to make all
the stuff work properly. Numpy is amazing by the way! I had no idea how easy
you can work with huge arrays!

My new issue is that I need to mask the land areas in the Z array so I would
have a clean plot over the basemap. Any ideas on how to achieve that?

Thanks,
Anton


Jeff Whitaker wrote:
> 
> antonv wrote:
>> It seems that I just cannot grasp the way the data needs to be formatted
>> for
>> this to work...
>> I've used the griddata sample that James posted but it takes about 10
>> minutes to prep the data for plotting so that solution seems to be out of
>> discussion.
>>
>> I guess my issue is that I don't know what type of data is required by
>> contourf function. Also as Jeff was saying earlier, the data is read from
>> a
>> grib file so supposedly it's already gridded. I've also looked at the
>> basemap demo
>> (http://matplotlib.sourceforge.net/users/screenshots.html#basemap-demo)
>> and
>> the data is read from 3 files, one for Lat one for Long and the Last for
>> Z
>> Data. Is there a way to automatically extract the data from the grib file
>> to
>> a format similar to the one used in the basemap example?
>>   
> 
> Anton: I just looked at your csv file and I think I know what the 
> problem is.  Whatever program you used to dump the grib data did not 
> write all the data - the missing land values were skipped.  That means 
> you don't have the full rectangular array of data.  I think you have two 
> choices:
> 
> 1) insert the missing land values into the array, either in the csv file 
> or into the array after it is read in from the csv file.  What program 
> did you use to dump the GRIB data to a CSV file?
> 
> 2) use a python grib interface.  If you're on Windows, PyNIO won't 
> work.  I've written my own module (pygrib2 - 
> http://code.google.com/p/pygrib2) which you should be able to compile on 
> windows.  You'll need the png and jasper (jpeg2000) libraries, however.
> 
> I recommend (2) - in the time you've already spent messing with that csv 
> file, you could have already gotten a real python grib reader working!
> 
> -Jeff
>>
>>
>> Jeff Whitaker wrote:
>>   
>>> Mauro Cavalcanti wrote:
>>>     
>>>> Dear Anton,
>>>>
>>>> 2008/12/23 antonv <vasilescu_an...@yahoo.com>:
>>>>   
>>>>       
>>>>>  Also, because I figured out the data I need and already have the
>>>>> scripts in place
>>>>> to extract the CSV files I would really like to keep it that way.
>>>>> Would
>>>>> it be possible to
>>>>> just show me how to get from the csv file to the plot?
>>>>>     
>>>>>         
>>>> Here is a short recipe:
>>>>
>>>> import numpy as np
>>>>
>>>> f = open("file.csv", "r")
>>>> coords = np.loadtxt(f, delimiter=",", skiprows=1)
>>>> lon = coords[:,0]
>>>> lat = coords[:,1]
>>>> dat = coords[:,2]
>>>>
>>>> where "file.csv" is a regular comma-separated values file in the
>>>> format:
>>>>
>>>> Lat,Lon,Dat
>>>> -61.05,10.4,20
>>>> -79.43,9.15,50
>>>> -70.66,9.53,10
>>>> -63.11,7.91,40
>>>> ...
>>>>
>>>> Hope this helps!
>>>>
>>>> Best regards,
>>>>
>>>>   
>>>>       
>>> Since the arrays are 2D (for gridded data), a reshape is also needed,
>>> i.e.
>>>
>>> lon.shape = (nlats,nlons)
>>> lat.shape = (nlats,nlons)
>>> data.shape = (nlats,nlons)
>>>
>>> You'll  need to know what the grid dimensons (nlats,nlons) are.
>>>
>>> -Jeff
>>>
>>> ------------------------------------------------------------------------------
>>> _______________________________________________
>>> Matplotlib-users mailing list
>>> Matplotlib-users@lists.sourceforge.net
>>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>>>
>>>
>>>     
>>
>>   
> 
> 
> ------------------------------------------------------------------------------
> _______________________________________________
> Matplotlib-users mailing list
> Matplotlib-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Plotting-NOAA-data...-tp21139727p21199108.html
Sent from the matplotlib - users mailing list archive at Nabble.com.


------------------------------------------------------------------------------
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to