NOTICE: This version of the NSF Unidata web site (archive.unidata.ucar.edu) is no longer being updated.
Current content can be found at unidata.ucar.edu.
To learn about what's going on, see About the Archive Site.
>From: "Fingerhut, William A" <address@hidden> >Organization: Lyndon State College >Keywords: 200401231403.i0NE3Dp2024942 Hi Bill- Sorry for the delay in responding. I wanted to be able to devote some time to answering. re: jython methods >Thanks. I hope to write more methods and I would like to do them >correctly. Great. We'll just have to figure out how to incorporate them into the system so others can use them. >The example in the IDV user guide was a good start for me. Everything >seemed >to make sense. Doing grid math without explicitly codeing loops is nice. >Not having to dimension arrays confuses me some -- read on. Glad the docs helped. We're in the process of revamping them so if there are any suggested improvements, let us know. >Once I found the method to extract pressure levels from a 3-d grid, I >was >ready to start. With one line of code I calculated temperature at all >grid >points in a constant lapse rate atmosphere. Easy! Sometimes it just amazes me how things just seem to work in the IDV. >However, above the tropopause the lapse rate has a different value. So, I >need to use slightly different logic for different portions of the domain. >It appears that I need to use array elements and explicitly code loops? Yes. I think the approach you took is correct. >The user guide does not address how to do this? Okay, I'll add that to the list of improvements. I think it might be best to point to Tom W's tutorial. >I found the syntax of for and if, and the len and range functions. Using range >in the for statement is a little strange; seems like there should be a better >way? No, that's how I'd do it. >Then, I added a loop to change the temperature values above the tropopause. >This worked and I was pretty happy. However, I am wondering if I shouldn't >use something similar to: > for i in range(len(t)): > z=p[i] > if z < 225.: > tstd[i]=216.65 > else: > tstd=288.15*(z/1013.25)**(287.05*.0065/9.806) >I didn't try this, but I was wondering if jython would create the tstd >array with the correct dimensions from this code? If I preceeded this code >with tstd=t it might? Actually, it will give you an error, because the result of the math is different from the type of the actual data. I tried: def tempAnom2(t): """ temperature anomoly from U.S. Standard Atmosphere """ # get pressure levels of temperature grids tmp=extractPressureFromNWPGrid(t) # calculate temperature for a constant lapse rate (6.5 C/km) atmosphere # change temperature in stratosphere to isothermal (216.65 K) for i in range(len(tmp)): p=tmp[i] if p < 225: tmp[i]=216.65 else: tmp[i]=288.15*(p/1013.25)**(287.05*.0065/9.806) # calculate the temperature anomoly tanom=t-tmp return tanom but it erred out when trying to do the tmp[i]. In your formula, if you wanted to use pressure as the deciding factor instead of temp, you could do: for i in range(len(p)): z=p[i] if p < 225: tstd[i]=216.65 since p and tstd have the same dimensionality. >Anyway, here is what I came up with. Do you have any suggestions for better >ways to do things? > >def tempAnom(t): > """ temperature anomoly from U.S. Standard Atmosphere """ > # get pressure levels of temperature grids > p=extractPressureFromNWPGrid(t) > # calculate temperature for a constant lapse rate (6.5 C/km) >atmosphere > tstd=288.15*(p/1013.25)**(287.05*.0065/9.806) > # change temperature in stratosphere to isothermal (216.65 K) > for i in range(len(tstd)): > z=tstd[i] > if z < 216.65: > tstd[i]=216.65 > # calculate the temperature anomoly > tanom=t-tstd > return tanom It worked, ship it! re: bundle >I know the technology exists and you are really good, but the attachment > >was not the bundle, but an image I created using the above method. The >confusion might be due to the fact that the file name does not have an >extension, like .jpg . I created the image (hope I remember this right) >from the vertical cross section control, one of the menus, save image. >I assumed the IDV would add the filename extension so I did not specify >one. Should the IDV do this for the user? When I did this in my 1.1 b2 version, it put the .jpg extension on it. If you can figure out exactly how you saved this and it's different from the above, let me know. Is this on windows or linux? >This vertical cross section nicely shows that where the troposphere is >colder than normal, the stratosphere is warmer than normal, etc. Cool. >I just tried to open the bundle file, and it failed. > >Failed to open C:\Documents and Settings\waf01060.LSC\My >Documents\IDV\Anom_Temp.xidv Data object "C:\Documents and >Settings\waf01060.LSC\My Documents\IDV\Anom_Temp.xidv" not compatible >with "VisADDataSource" data family >ucar.unidata.data.BadDataException: Failed to open C:\Documents and >Settings\waf01060.LSC\My Documents\IDV\Anom_Temp.xidv Data object >"C:\Documents and Settings\waf01060.LSC\My Documents\IDV\Anom_Temp.xidv" >not compatible with "VisADDataSource" data family at >ucar.unidata.data.DataManager.createDataSource(DataManager.java:650) >at >ucar.unidata.idv.IntegratedDataViewer.createDataSource(IntegratedDataVie >wer.java:3684) > >Does this have something to do with my method, or ??? Did you get this error when opening from the File/URL chooser in the Data Source selector? For bundles, you have to use the File->Open... menu to load them in. But, we'll look into changing the File chooser to allow bundles. You can load bundles in from the URL chooser, so you should be able to from the File chooser as well. I'm cc'ing Tom W. on this response in case he has any thoughts on how your procedure could work better. I can think of things, but it involves knowing too much about the VisAD data structure. I think what you did is great because you don't know anything about the VisAD structure and it worked! Good job. Don NOTE: All email exchanges with Unidata User Support are recorded in the Unidata inquiry tracking system and then made publically available through the web. If you do not want to have your interactions made available in this way, you must let us know in each email you send to us.