Anda di halaman 1dari 5

function true2lon,rgb

;rgb is array of lonarr(3)


return,(long(rgb[0]) or ishft(long(rgb[1]),8) or ishft(long(rgb[2]),16))
end
;*****************************************************************
pro extract_and_draw_modis_chlor_monthly_cut_area_jumsar_sawu
;==========================================
!p.background='ffffff'x
!p.color=0
;=====================================
;***************************
;*****************************************
;;!P.Region=[0.02,0.09,0.98,0.98]
!P.Position=[0.07,0.05,0.95,0.96]
;======================colorbar==========================
loadct,33,/silent
tvlct,r,g,b,/get
rgb1=(long(r) or ishft(long(g),8) or ishft(long(b),16))
rgb2=[[[rgb1 and 'ff'x]],[[ishft(rgb1 and 'ff00'x,-8)]],[[ishft(rgb1 and 'ff0000'x,-16)]]]
;*********************************************************************
xsize=600 (untuk memperbesar layar ke atas dan bawah)
ysize=800 (untuk memperbesar layar ke kiri dan kanan)
bar_length=fix(xsize*0.7)
rgb3=byte(congrid(rgb2,bar_length,15,3))

year_start=2013 (tahun Star yang akan ditampilkan )


year_end=2013 (tahun akhir yang akan ditampilkan)
;***********************************************************************1000
for year=year_start,year_end do begin
;stop
year_st=strtrim(string(year),2)
julyear= julday(1,1,year)

;
=======================================================
=============
path_list='E:\Data\modis\chlor\monthly\'+year_st+'\A'+year_st+'*.nc.'

datafiles=findfile(path_list,count=num_files)
;stop
if num_files gt 0 then begin
for files=0,num_files-1 do begin
;stop
pos_filename=strpos(datafiles[files],'\A')

filename=strtrim(strmid(datafiles[files],pos_filename+2,7),2)
dateth_st =strtrim(strmid(filename,4,3),2)
dateth = fix(dateth_st)-1
juldate=julyear+dateth
caldat,juldate,month,day,year
;stop
month_st = strtrim(string(month,format='(I2.2)'),2)
;stop
;
=======================================================
====================
fid=NCDF_OPEN(datafiles[files])
varnames = ncdf_vardir(fid);----------------------searching variabel
;stop
NCDF_VARGET, fid,0,chlor_a
NCDF_VARGET, fid,1,lat
NCDF_VARGET, fid,2,lon
lonmin=min(lon)
latmin=min(lat)
grid_interval=(lon[1]-lon[0])
;grid_interval2=(lat[0]-lat[1])
dimens=size(chlor_a,/dim)
widht=dimens[0]
height=dimens[1]
;stop
attnames = ncdf_attdir(fid,'chlor_a');------------------searching attributes for 'sst' variable
NCDF_ATTGET,fid,'chlor_a','add_offset',add_offset
NCDF_ATTGET,fid,'chlor_a','scale_factor',scale_factor
ncdf_attget,fid,'chlor_a','units',units
ncdf_attget,fid,'chlor_a','valid_min',valid_min
ncdf_attget,fid,'chlor_a','valid_max',valid_max
print, add_offset
print,scale_factor
NCDF_CLOSE,fid
;stop
;==================================================
index=where((chlor_a lt -300)or(chlor_a gt 100),count)
sst_map=chlor_a*scale_factor+add_offset
sst_map[index]=999.0
sst_map=rotate(sst_map,7)
;stop
;======================================================
;=====================================
window,0,xsize=xsize,ysize=ysize;,/pixmap
;======================output into image file)

;==================set map==========================
;;---------------indonesia
;latmin_cut=-10
;lonmin_cut=95.
;latmax_cut=10.
;lonmax_cut=145.
;---------------sawu
latmin_cut=-12.0
lonmin_cut=116.0
latmax_cut=-4
lonmax_cut=130.0

Untuk
Crop
daerah/lokasi
sesuai lokasi yang akan di teliti
dalam hal ini laut sawu

lon_beg = lonmin_cut
lon_end = lonmax_cut
lat_beg = latmin_cut
lat_end = latmax_cut
a = fix ((lon_beg-lonmin)/grid_interval)
b = fix ((lon_end-lonmin)/grid_interval)
c = fix ((lat_beg-latmin)/grid_interval)
d = fix ((lat_end-latmin)/grid_interval)
;stop
sst_map2 = sst_map[a:b,c:d]
dimens=size(sst_map2,/dim)
widht=dimens[0]
height=dimens[1]
lon2=lonmin_cut+findgen(round(widht))*grid_interval
lat2=latmin_cut+findgen(round(height))*grid_interval
;stop
map_set,0,180,limit=[latmin_cut,lonmin_cut,latmax_cut,lonmax_cut],/iso
max_value=1.0;maxmax
min_value=0.0
index_max=where((sst_map gt max_value)and(sst_map lt 999),count_max)
if (count_max ne 0)then sst_map[index_max]=max_value
index_min=where(sst_map lt min_value,count_min)
if (count_min ne 0)then sst_map[index_min]=min_value
;**************************************************************************
level_interval=0.01
numlevel=fix((max_value-min_value)/level_interval+1)
col=lonarr(numlevel)
for e=0,numlevel-1 do begin
cc=byte(e*level_interval/(max_value-min_value)*255)
col[e]=true2lon(rgb2[cc,0,*])
endfor
levels=findgen(numlevel)*level_interval+min_value
;sst_map=rotate(sst_map,7)

contour,sst_map2,lon2,lat2,/overplot, $
max_value=max_value, $
min_value=min_value, $
levels=levels, $
/cell_fill, $
;c_labels=intarr(num_l)+1, $
;c_charsize=3, $
;c_charthick=2.5, $
;c_thick=3.0, $
font=1, $
c_colors=col[indgen(numlevel)]
;
=======================================================
============
map_continents,/coasts,mlinethick=2.5,/hires
map_grid,/box_axes,londel=2, latdel=2,charsize=1.5,charthick=2.0
;stop
;
=======================================================
=========
;===================================
tv,rgb3, tr=3,0.15,0.064,/normal
;
=======================================================
===============
interval_measure=0.1
num_interval=round((max_value-min_value)/interval_measure)
for w=0,num_interval do begin
index_value=w*(max_value-min_value)/float(num_interval)+min_value
index_plot=string(index_value,format='(F5.1)')
x_position=0.15+0.7/num_interval*w
y_position=0.02
xyouts,x_position,y_position,index_plot,charsize=2,charthick=2,font=1,/normal,alignment=
0.5
endfor
;===========================
title2='MODIS Chlorophyl-a Indonesia '+year_st+month_st
XYOUTs,0.5,0.9,title2,/normal,alignment=0.5,charsize=2.5,charthick=1.5,font=1;,color=2
55
XYOUTs,0.5,0.11,'Longitude (!U0!
NE)',/normal,alignment=0.5,charsize=2.,charthick=2.5,font=1, color='000000'xl
XYOUTs,0.02,0.5,'Latitude (!U0!
NN)',/normal,alignment=0.5,charsize=2.,charthick=2.5,font=1, orientation=90,
color='000000'xl
unit_st='(mg/m!u3!n)'
XYOUTs,0.95,0.02,unit_st,/normal,alignment=0.5,charsize=2.,charthick=2.0,font=1;,color
=255
;=====================================================

;=======================================ps output
;stop
;=====================================tiff output==
file_mkdir, 'E:\Data\modis\chlor\Sawu\'+year_st
path_output='E:\Data\modis\chlor\Sawu\'+year_st+'\chlor_'+year_st+month_st+'.png'
(untuk output Gambar)
;==================================================
T=TVRD(channel=0,true=1,order=0)
write_png,path_output,T
;=========================
endfor
endif
;stop
endfor
;
=======================================================
===1000
;===================end of pro
print,'finished'
stop
;================================reset the system parameter
!P.Region=0
!P.Position=0
end