how to load data locally from scrip, without using bundle

Cool displays
User avatar
tomw
Posts: 296
Joined: Tue Dec 23, 2008 3:40 pm

Re: how to load data locally from scrip, without using bundle

Post by tomw »

You might want to check to be sure your files have temperatures in deg_K in them. Try printing out a couple of values. For example, inside your nested 'for loops' do something like:

Code: Select all

if i==100 and j==100: print data[0][i][j];


You might also just display one of the files in McV and see what the "probe" gives you.
User avatar
glez_b
Posts: 87
Joined: Thu May 05, 2011 9:19 pm
Contact:

Re: how to load data locally from scrip, without using bundle

Post by glez_b »

My database is composed of monthly and is the Following:

200406010000.goes10ir
200406010000.goes10vis
200406010000.goes10wv
200406010000.goes12ir
200406010000.goes12vis
200406010000.goes12wv

Each has 3 channels: ir, vis, wv with four variables: raw, radiance, brightness and temperature.
I am interested in data format: .goes12ir and variable temperature.
How I can make that filter data and where in the code could add that filter.
I have done tests in the McIDAS-V, I just want the range with TIR <-219 K
Boris_MCS
User avatar
tomw
Posts: 296
Joined: Tue Dec 23, 2008 3:40 pm

Re: how to load data locally from scrip, without using bundle

Post by tomw »

Hi Boris...

I do not know how you obtained your image files, but usually an ADDE server will return only one calibration type (radiance, temperature, brightness, etc). You will need to check on this. It is possible that you received IR data that is not calibrated for "temperature".

Regarding all the image files you have in the directory -- I suggest that when you loop through the filenames, you look for "ir", and only read the file if that is matched. Since this is just a "string", you could use the string.find() function to see if "ir" appears in the filename, and then only process those files.

tom
User avatar
glez_b
Posts: 87
Joined: Thu May 05, 2011 9:19 pm
Contact:

Re: how to load data locally from scrip, without using bundle

Post by glez_b »

Not very clear to me how to find files with extension goes12ir. Because I'm interested in that, once the data is located with the value of TIR = 219K select the data that maintain the value TIR for three hours or more.



My data if they are calibrated. I have a doubt in the statement "if".
which means the value of 100, are temperature or brightness values???
I guess the statement if (data [0] [i] [j]> 199.5) and (data [0] [i] [j] <200.5)
must be replaced by if i ==100 and j==100: print data [0] [i] [j];

Sorry for all this trouble, but it's hard for me.
Boris_MCS
User avatar
tomw
Posts: 296
Joined: Tue Dec 23, 2008 3:40 pm

Re: how to load data locally from scrip, without using bundle

Post by tomw »

hi Boris...
glez_b wrote:Not very clear to me how to find files with extension goes12ir. Because I'm interested in that, once the data is located with the value of TIR = 219K select the data that maintain the value TIR for three hours or more.

The first step is to find out if your files have been calibrated to temperature. How did you obtain the files?

My data if they are calibrated. I have a doubt in the statement "if".
which means the value of 100, are temperature or brightness values???

I understand your point....although if you got a value of, say, 100....it's probably not a temperature. In McV, use the Data Explorer to read the file (as a "File", not using the "Image Chooser") and select the Type as McIDAS AREA file. Display this and see what kinds of values you get.

I guess the statement if (data [0] [i] [j]> 199.5) and (data [0] [i] [j] <200.5)
must be replaced by if i ==100 and j==100: print data [0] [i] [j];


That was the idea but I agree that it was not a good one -- just display the image as described above and prove around with the middle mouse button....

Sorry for all this trouble, but it's hard for me.

[/quote]
Hopefully, this will ultimately help others.

tom
User avatar
glez_b
Posts: 87
Joined: Thu May 05, 2011 9:19 pm
Contact:

Re: how to load data locally from scrip, without using bundle

Post by glez_b »

I followed your suggestions (in the attachment show the procedure and data types). Data is downloaded from unidata2.ssec.wisc.edu, via ftp. The features of the data are explained in [url]http://www.unidata.ucar.edu/data/unirec.html.
[/url]
When I deploy the data in McV, I get brightness values ??(0-255). So I want to detect values ??of 200 and that this value is maintained for 3 hours or more, if not so do not select.
Boris_MCS
User avatar
glez_b
Posts: 87
Joined: Thu May 05, 2011 9:19 pm
Contact:

Re: how to load data locally from scrip, without using bundle

Post by glez_b »

The region of interest is Mexico
Attachments
datoss-ssec3.png
datos-SSEC.png
Boris_MCS
User avatar
tomw
Posts: 296
Joined: Tue Dec 23, 2008 3:40 pm

Re: how to load data locally from scrip, without using bundle

Post by tomw »

Hi Boris...

It looks like you have "brightness" values in your files and not temperatures.

I would like to look at one of your files -- would you please ftp one of the files to our server at:
ftp.ssec.wisc.edu and put it into the "pub/incoming" directory and let me know the name of the file.

Thanks.
User avatar
glez_b
Posts: 87
Joined: Thu May 05, 2011 9:19 pm
Contact:

Calculatiing Area of pixels

Post by glez_b »

I put the file 200406010115.goesir in "/ put / incoming."
Make a run with the following script:

Code: Select all

 def scm(directory):
              import os;
              fs = os.listdir(directory);

  # now fs will be a list of all the files in directory

         from edu.wisc.ssec.mcidas import AreaFile;
         for name in fs:

             print "Reading in:",name
             af = AreaFile(directory+"/"+name);
             ad = af.getAreaDirectory();
             count = 0;
             data = af.getFloatData();

      # now look through the first band y count pixels
      # MCS detected when his temperature infrared (TIR) is < 219 K

            for i in xrange(ad.getLines()):
                 for j in xrange(ad.getElements()):
                       if (data[0][i][j]) == 200:
            print "For file",name," count = ",count
         scm("/home/mcidasv/Documentos/SSEC/20040601")

it is working well and i get the following:
Reading in: 200406010145.goes12ir
For file 200406010145.goes12ir count = 3126
Reading in: 200406010545.goes12ir
For file 200406010545.goes12ir count = 4455
Reading in: 200406012115.goes12ir
For file 200406012115.goes12ir count = 4690
Reading in: 200406010915.goes12ir
For file 200406010915.goes12ir count = 3373
Reading in: 200406010315.goes12ir
For file 200406010315.goes12ir count = 2390
Reading in: 200406011945.goes12ir
For file 200406011945.goes12ir count = 5902
Reading in: 200406010715.goes12ir
For file 200406010715.goes12ir count = 4644
Reading in: 200406011715.goes12ir
For file 200406011715.goes12ir count = 5613
Reading in: 200406012145.goes12ir
For file 200406012145.goes12ir count = 3976
Reading in: 200406010845.goes12ir
For file 200406010845.goes12ir count = 5269
Reading in: 200406011345.goes12ir
For file 200406011345.goes12ir count = 4895
Reading in: 200406010445.goes12ir
For file 200406010445.goes12ir count = 3910
Reading in: 200406011515.goes12ir
For file 200406011515.goes12ir count = 3563
Reading in: 200406010015.goes12ir
For file 200406010015.goes12ir count = 2684
Reading in: 200406011315.goes12ir
For file 200406011315.goes12ir count = 4915
Reading in: 200406011745.goes12ir
For file 200406011745.goes12ir count = 6666
Reading in: 200406010115.goes12ir
For file 200406010115.goes12ir count = 3095


The values ??shown in "count" correspond to the number of pixels whose value is 200? If this is so, I have a problem here because the script take into account all the pixels whose value is 200, how I can do to only count the pixels whose value of 200 is kept for three hours or more and that only counts for the region of Mexico (32 N, 14 N, -120 W,-80W)?

Display image for data 200406010115.goes12ir (attached)
Attachments
IR.jpg
Boris_MCS
User avatar
tomw
Posts: 296
Joined: Tue Dec 23, 2008 3:40 pm

Re: Calculatiing Area of pixels

Post by tomw »

Hi Boris...

Thank you for the file. I am happy to see you have things running better now.

You asked:
glez_b wrote:The values ??shown in "count" correspond to the number of pixels whose value is 200?

Yes...(assuming there is a "count = count + 1" statement in there -- didn't see it in your posting).....but that is not where the temperature is < 219K. For that you either need AREA files with temperature, or perhaps use the "IR brightness to brightness_temperature" computation.

Further:
If this is so, I have a problem here because the script take into account all the pixels whose value is 200, how I can do to only count the pixels whose value of 200 is kept for three hours or more

I suggest creating another array which has as many elements as you have in your images, and initializing it to zeroes. Then as you loop through all the pixels in each image and each time you find a desired value (whether it is 200 or something else), you would then increment the corresponding cell in that array. At the end, you could look through that array and see what totals are values that indicate "greater than three hours".

Or something like that....

If you really want to "track" features that persist for a longer time, or compute the area of such things, that is another research topic for which many people are actively working on....not something that I can solve for sure...

and that only counts for the region of Mexico (32 N, 14 N, -120 W,-80W)?

You would have to determine the first and last "lines" and "elements" for the region you want, and then change the 'xrange()' values accordingly. Suppose the lines you want go from 612 to 933, and the elements go from 85 to 322...then your loops would be something like this:

Code: Select all

for i in xrange(612,933):
    for j in xrange(85,322):
Post Reply