Re: How to fix this image

From: Karin Meier-Fleischer <meier-fleischer_at_nyahnyahspammersnyahnyah>
Date: Tue Jul 22 2014 - 02:38:48 MDT

Hi Ipshita,

if I'm understanding your problem right it is a latitude/longitude
problem that you get your data displayed in a square region instead of
plotting each grid box at the correct lat/lon position.
I don't really understand some parts of your script because it is
difficult to help without knowing your data. So, please send a
printVarSummary(sce), but I tried to get into your script and made some
corrections.

;*******************************************
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"

a =addfile("~/Documents/Snow_cover_IMS/nhsce_v01r01_19661004_20140602.nc
<http://nhsce_v01r01_19661004_20140602.nc>","r")
sce=a->snow_cover_extent(0,:,:)

lat=a->latitude ;-- if you want the complete array you
don't have to use (:,:)

print(lat(:,1))

lon=a->longitude ;-- if you want the complete array you
don't have to use (:,:)

;print(sce)
;print("Hello")
;printVarSummary(sce)
;printVarSummary(lat)
;printVarSummary(lon)

;;; delete_VarAtts(sce, -1);-- why are you deleting all variable
attributes??

;Attaching variables
;;sce!0="lat2d" ;-- no
;;sce!1="lon2d";-- no

sce@lat2d=lat
sce@lon2d=lon

printVarSummary(sce)

; Plotting code

wks = gsn_open_wks("ps","sce_ims")
gsn_define_colormap(wks,"default")

res = True
res@cnFillOn = True
res@cnLinesOn = False
res@cnLineLabelsOn = False
res@cnFillMode = "rasterfill"
res@cnMissingValFillColor = 28 ; "gray"
;
; Since the data is categorical, values between the categories need to be
; excluded. Use Explicit level selection to accomplish this.
;
res@cnLevelSelectionMode = "explicitlevels"
res@cnLevels = (/ 0.99,1.99, 2.99, 3.99, 4.99 /)
res@cnFillColors = (/ 1, 4, 19, 6, 0, 1 /) ; (/"black", "blue", "green",
"yellow", "white", "black" /)
res@lbLabelAlignment = "boxcenters"
res@lbLabelStrings = (/ "water", "land", "ice", "snow" /)
;
; First draw the plot without projecting into map coordinates.
; This has the drawback that only index values are used as tick marks
; but it is fast
;
res@gsnPolar = "NH" ; specify the hemisphere
  plot = gsn_csm_contour_map_polar(wks,sce,res) ; create the plot
;*******************************************

Hope this will help,
Karin


Am 21.07.14 20:57, schrieb Ipshita Majhi:
> I have the Print Var summary. I was wondering how to remove the black
> background. I want put boxes around the arctic extract the data
> specified by those boxes based on those latitude and longitude
>
>
>
> On Sat, Jul 19, 2014 at 8:40 AM, Alan Brammer <abrammer@albany.edu
> <mailto:abrammer@albany.edu>> wrote:
>
> If your file is the same as the one I just pulled from the below
> location. Then snow_cover_extent apparently only has 2 values (0
> or 1) for no_snow or snow_covered.
>
>
> ftp://cdr.ncdc.noaa.gov/cdr/snowcover/nhsce_v01r01_19661004_20140630.nc
>
>
> Check a ncl_filedump of the file and you'll possibly see the below:
>
> byte snow_cover_extent ( time, rows, cols )
> long_name :NOAA/NCDC Climate Data Record of snow cover extent
> standard_name :surface_snow_binary_mask
> grid_mapping :coord_system
> coordinates :longitude latitude time snow_cover_threshold
> valid_range :( 0, 1 )
> flag_values :( 0, 1 )
> flag_meanings :no_snow snow_covered
> _FillValue :-9
>
>
>
> If the contour levels wasn't the issue, reply to the list with
> more specifics.
>
>
>
> Alan.
>
>
>
> ##############################
> Alan Brammer,
> PhD Student,
>
> Department of Atmospheric and Environmental Sciences,
> University at Albany, State University of New York, Albany, NY, 12222
> abrammer@albany.edu <mailto:abrammer@albany.edu>
> ##############################
>
> On Jul 18, 2014, at 8:04 PM, Ipshita Majhi <ipmajhi@alaska.edu
> <mailto:ipmajhi@alaska.edu>> wrote:
>
>> I have plotted snow cover data and I have attached lat and lon to
>> it and when I plot I get this image
>>
>> Here is my code:-
>> ;*******************************************
>> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
>> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
>> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
>>
>> a
>> =addfile("~/Documents/Snow_cover_IMS/nhsce_v01r01_19661004_20140602.nc
>> <http://nhsce_v01r01_19661004_20140602.nc/>","r")
>> sce=a->snow_cover_extent(0,:,:)
>>
>> lat=a->latitude(:,:)
>>
>> print(lat(:,1))
>>
>> lon=a->longitude(:,:)
>> ;print(sce)
>> ;print("Hello")
>> ;printVarSummary(sce)
>> ;printVarSummary(lat)
>> ;printVarSummary(lon)
>>
>> delete_VarAtts(sce, -1)
>>
>> ;Attaching variables
>> sce!0="lat2d"
>> sce!1="lon2d"
>>
>> sce@lat2d=lat
>> sce@lon2d=lon
>>
>>
>>
>> printVarSummary(sce)
>>
>>
>> ; Plotting code
>>
>> wks = gsn_open_wks("ps","sce_ims")
>> gsn_define_colormap(wks,"default")
>>
>>
>> res = True
>> res@cnFillOn = True
>> res@cnLinesOn = False
>> res@cnLineLabelsOn = False
>> res@cnFillMode = "rasterfill"
>> res@cnMissingValFillColor = 28 ; "gray"
>>
>> ;
>> ; Since the data is categorical, values between the categories
>> need to be
>> ; excluded. Use Explicit level selection to accomplish this.
>> ;
>>
>> res@cnLevelSelectionMode = "explicitlevels"
>> res@cnLevels = (/ 0.99,1.99, 2.99, 3.99, 4.99 /)
>> res@cnFillColors = (/ 1, 4, 19, 6, 0, 1 /) ; (/"black", "blue",
>> "green", "yellow", "white", "black" /)
>> res@lbLabelAlignment = "boxcenters"
>> res@lbLabelStrings = (/ "water", "land", "ice", "snow" /)
>>
>> ;
>> ; First draw the plot without projecting into map coordinates.
>> ; This has the drawback that only index values are used as tick
>> marks
>> ; but it is fast
>> ;
>> res@gsnPolar = "NH" ; specify the
>> hemisphere
>> plot = gsn_csm_contour_map_polar(wks,sce,res) ; create the plot
>>
>>
>> What is missing?
>>
>> <sce_ims.ps
>> <http://sce_ims.ps>>_______________________________________________
>> ncl-talk mailing list
>> List instructions, subscriber options, unsubscribe:
>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>



_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk


Received on Tue Jul 22 08:39:20 2014

This archive was generated by hypermail 2.1.8 : Wed Jul 23 2014 - 15:33:46 MDT