miss matched latitude and longitude (x, y) in nctoolbox and ncview

60 views
Skip to first unread message

CKS

unread,
Apr 25, 2013, 7:49:36 AM4/25/13
to ncto...@googlegroups.com
Dear all,

I've tried to figure out why I did not get the same data from nctoolbox and ncview. However, I did get identical results at some locations.


(1) identical result:

-- using nctoolbox

dir = '/Users/changks/IBIS/canada-10km/normals_wetd/wetd_sensitivity';

wetd_x100 = 'original/wetd.mon.nc';

ds_wetd_x100  = ncgeodataset('wetd.mon.nc'); obj_ds_wetd_x100  = ds_wetd_x100.geovariable('wetd');

SK_OA.lat = 147; SK_OA.lon = - (360 - 188); 

SK_OBS.lat = 149; SK_OBS.lon = - (360 - 196); 

SK_OJP.lat = 148; SK_OJP.lon = -(360 - 198); 

wetd_x100_SK_OA = obj_ds_wetd_x100.geosubset(SK_OA).data;

wetd_x100_SK_OBS = obj_ds_wetd_x100.geosubset(SK_OBS).data;

wetd_x100_SK_OJP = obj_ds_wetd_x100.geosubset(SK_OJP).data;

plot(wetd_x100_SK_OA,'LineWidth',2,'LineStyle','--','Color',[0 0 0]); hold on

plot(wetd_x100_SK_OBS,'LineWidth',2,'LineStyle','--','Color',[0 0 0]); hold on

plot(wetd_x100_SK_OJP,'LineWidth',2,'LineStyle','--','Color',[0 0 0]); hold on


-- using ncview

$ ncview wetd.mon.nc

  --> move your cursor to (x = 188, y = 147), (x = 196, y = 149) and (x = 198, y = 148)

  --> double click to show the trend line at that location

  --> you will see the results are identical with that in nctoolbox.



- different results:

try locations : (x = 383, y = 32), (x = 410, y = 117) and  (x = 406, y = 120)


I also attached the nc file that I'm trying to solve this puzzle at http://db.tt/WIqIt2u1

Are there anyone can help me to figure it out why I did not get the same trend lines at some locations in nctoolbox? 

Thank you for your help.


Cheers,

Michael

Rich Signell

unread,
Apr 25, 2013, 9:03:55 AM4/25/13
to ncto...@googlegroups.com
Michael,

I think the problem is that although your longitude and latitude variables have units of "degrees_east" and "degrees_north", the values are clearly not decimal degrees.  This causes the automatic extraction of the grid using geovariable methods to get confused.   Try modifying your lon/lat values to be actual degrees and see if you still have the problem.   The code and plots below compare extracting the lon,lat values explicitly, and using the geovariable methods:

nc = ncgeodataset('c:/users/rsignell/downloads/wetd.mon.nc');
wetd_var
= nc.geovariable('wetd');

wetd
= squeeze(wetd_var.data(1,1,:,:));

% plot with explicitly referenced lon,lat grid
subplot
(121)
lon
= nc.data('longitude');
lat
= nc.data('latitude');
pcolorjw
(lon,lat,wetd)
title
('Explicit lon,lat values')

% plot using geovariable method for extracting grid
subplot
(122)
wetd_grid
= squeeze(wetd_var.grid_interop(1,1,:,:));
pcolorjw
(wetd_grid.lon,wetd_grid.lat,wetd)
title
('Using geovariable-derived lon,lat values')

This produces the attached plot.



-Rich
4-25-2013 8-58-57 AM.png

Kuo-Hsien Chang

unread,
Apr 25, 2013, 11:27:35 AM4/25/13
to ncto...@googlegroups.com
Thanks Rich. Now I understand it. 

I extract the data at particular location (i.e., referenced lon,lat grid) by using:

wetd_location = squeeze(wetd_var.data(1:12,1,lat(32),lon(383)))

Cheers,

Michael



--
You received this message because you are subscribed to a topic in the Google Groups "nctoolbox" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/nctoolbox/lbnFlC_2Bw8/unsubscribe?hl=en-US.
To unsubscribe from this group and all its topics, send an email to nctoolbox+...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 
<4-25-2013 8-58-57 AM.png>

Alexander Crosby

unread,
Apr 25, 2013, 12:23:36 PM4/25/13
to ncto...@googlegroups.com
I don't think that last command will work as you expect. The all the positions of the .data method should be indices, but it looks like you have mixed indices and lat/lon values. If you already know the x/y indices for the position you are interested in, you can just put them in in place of your lat(32),lon(383). If you only know the lat/lon you are interested in, you should use the function nj_tseries or something similar.


--
You received this message because you are subscribed to the Google Groups "nctoolbox" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nctoolbox+...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages