From: Peter K. <pet...@wa...> - 2013-05-27 20:30:06
|
Hi Yin, Thank you for doing additional testing. That is a rather perplexing bug. It is actually caused by a change in behaviour between numpy 1.6.2 and 1.7.1. python Python 2.7.3 (default, Jan 2 2013, 13:56:14) [GCC 4.7.2] on linux2 >>> import numpy as np >>> np.__version__ '1.6.2' >>> x, y = np.meshgrid(np.arange(0, 2, dtype=np.int16), np.arange(3, 5, dtype=np.float32)) >>> print x.dtype, y.dtype int16 float32 vs. python Python 2.7.3 (default, Jan 2 2013, 13:56:14) [GCC 4.7.2] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import numpy as np >>> np.__version__ '1.7.1' >>> x, y = np.meshgrid(np.arange(0, 2, dtype=np.int16), np.arange(3, 5, dtype=np.float32)) >>> print x.dtype, y.dtype int64 float64 The newer version does upcasting to 64 bits. I'm not sure if this is the intended behaviour, perhaps a bug report should be filed against numpy. In any case, this can be worked around by casting X, Y explicitly. I think your fix is essentially good, although I'd prefer casting with astype, as it creates contiguous arrays. Attached is a patch. Please let me know if it works for you. You are most welcome to modify the source code of ccplot, it is open source software, it makes me happy to see contributions and bug reports from other people. I'll answer your other question about cloud mask soon. Btw. there is a new program in the making that is supposed to complement ccplot in browsing larger amount of granules. It is a web app, with server-side importing of granules. https://github.com/peterkuma/ccbrowse browse.ccplot.org (demo example, please open in recent firefox or chrome) Support for CloudSat is kind of secondary at the moment, as it requires CALIPSO granule to be imported first, so that relative time shift can be calculated correctly. It can be installed and used locally as well. Regards, Peter On 05/27/2013 05:19 AM, yinjinfang88 wrote: > Hi Peter, > Thanks very much for your fast reply. The CloudSat data (granule > number 14779) is 2009037050924_14779_CS_2B-GEOPROF_GRANULE_P_R04_E02.hdf > , which is a example data for ccplot. > You can download it at the web site > http://sourceforge.net/projects/ccplot/files/products/. I printed the > data type of the variables of data, X, Y, ve1, ve2, resolution, and > radius. There are shown as > print(data.dtype) ----> float32 > print(X.dtype) ----> float64 > print(Y.dtype) ----> int16 > print(ve1.dtype) ----> int16 > print(ve2.dtype) ----> int16. > It can be seen that the error message resulted from the data type of > variable X. I tried to add two key words of sparse=False, copy=False for > np.meshgrid function at lines 1498 and 1501, respectively. > Then the data type of variable X is shown as float32. Although the > ccplot works now, I don't know whether it is right or not. Because I > am a newer of Python. > > I have a another question. There is a variable named cloud_mask > in CloudSat data, which demonstrates the reliability of the Rader > reflectivity. I want to get rid of the Rader reflectivity when the value > of cloud_mask is less than 20. However, I don't know where I can add > some condition select and judgement sentences in ccplot. Could you > please show me a example? > > It is impolite to modify your source codes without any permission. I ask > for your forgiveness. > > Thanks again. > > Yin > > > ------------------------------------------------------------------------ > yinjinfang88 > > *From:* Peter Kuma <mailto:pet...@wa...> > *Date:* 2013-05-27 02:53 > *To:* yinjinfang88 <mailto:yin...@16...> > *CC:* ccplot-general <mailto:ccp...@li...> > *Subject:* Re: ccplot errors > On 05/26/2013 01:31 PM, yinjinfang88 wrote: >> Dear all, >> I run ccplot for visualising CloudSat data. However, I got a >> error at line 1504 in ccplot file. That is: >> data = cctk.interpolate2d(data, X, Y, (0, e2-e1, e2-e1), >> (ve1, ve2, resolution), float("nan"), 0, radius) >> and the error message is as follows: >> >> Traceback (most recent call last): >> File "/usr/local/bin/ccplot", line 2265, in <module> >> main(sys.argv) >> File "/usr/local/bin/ccplot", line 2183, in main >> opts=opts.plot_opts) >> File "/usr/local/bin/ccplot", line 1505, in plot_profile >> (ve1, ve2, resolution), float("nan"), 0, radius) >> TypeError: Cannot cast array data from dtype('float64') to dtype('float32') according to the rule 'safe' >> >> Did something wrong? >> Thinks! >> >> Yin > > Dear Yin, > > Thank you very much for the report. This is a bug in ccplot. Could you > please let me know what CloudSat granule it was and the command you > used? It'll be helpful in pinpointing and fixing the problem. > > Regards, > > Peter |