Документ взят из кэша поисковой машины. Адрес оригинального документа : http://lnfm1.sai.msu.ru/~kupry/SOFTWARE/bmp2fits_v2.0.pro
Дата изменения: Sun Oct 9 23:05:39 2011
Дата индексирования: Mon Oct 1 23:02:35 2012
Кодировка:

Поисковые слова: total solar eclipse
;
;
; ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
; + +
; + FUNCTIONS & PROCEDURES +
; + +
; ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;
;
;
pro sep_pathflnm,path_name,path,flnm,flext
; separate path, filename and extension from the whole path to file path_name
if(!version.os_family eq 'unix') then dir_separator='/'
if(!version.os_family eq 'Windows') then dir_separator='\'
posls=strpos(path_name,dir_separator,/reverse_search)
path=strmid(path_name,0,posls+1)
flnmwh=strmid(path_name,posls+1)
pospt=strpos(flnmwh,'.',/reverse_search)
flnm=strmid(flnmwh,0,pospt)
flext=strmid(flnmwh,pospt+1)
end
;
;
;
;
;
;
;
;
;
; +++++++++++++++++++++++++++++++++++++++++
; + +
; + MAIN CODE +
; + +
; +++++++++++++++++++++++++++++++++++++++++
;
;
;
;
fldir_in=dialog_pickfile(/directory,$
title='select directory containing BMP files')
;
print,' '
print,'Selected directory: '+fldir_in
srch_specfs=fldir_in+['*.bmp','*.BMP']
fl=file_search(srch_specfs,/fully_qualify_path,count=nfl)
;
fldir_out=dialog_pickfile(/directory,$
title='select directory where fits files will be saved')
;
;
for i=0,nfl-1L do begin
fl_in=fl[i]
sep_pathflnm,fl_in,path,flnm,flext
img_bmp=read_bmp(fl_in)
fits_write,fldir_out+'tmp.fits',img_bmp
fits_read,fldir_out+'tmp.fits',img_fts,hdr_fts
if(i eq 0) then begin
sss=size(img_bmp)
yx_figratio=float(sss[2])/float(sss[1])
xwinsize=400
ywinsize=round(float(xwinsize)*yx_figratio)
window,0,title='BMP image',xs=xwinsize,ys=ywinsize
tvscl,congrid(img_bmp,xwinsize,ywinsize)
window,1,title='FITS image',xs=xwinsize,ys=ywinsize
tvscl,congrid(img_fts,xwinsize,ywinsize)
i_dgstmn=0L
aglll01:
flip_hor_sw=0
flip_ver_sw=0
i_dgstmn=i_dgstmn+1L
if(i_dgstmn gt 1) then begin
window,1,title='FITS image',xs=xwinsize,ys=ywinsize
tvscl,congrid(img_fts,xwinsize,ywinsize)
endif
print,' W A R N I N G:'
print,'Always change orientation (if needed) of spectra images'
print,' in order to correspond with orientation orientation of'
print,' slit-jaw images. Be carreful and check orientation of'
print,' spectra in bmp images and leave out those which have dif-'
print,' ferent orientation that majority of images. These can be'
print,' transformed later individually to agree with orientation'
print,' of corresponding slit jaw'
print,' '
print,' press enter'
rrrg=get_kbrd()
print,' '
print,' '
print,'1) flip FITS img vertically'
print,'2) flip FITS img horizontally'
print,'3) flip FITS img both vertically and horizontally'
print,'4) leave FITS image as it is, it''s OK (default)'
print,' '
answ1=' '
read,answ1
rrr=where(answ1 eq ['1','2','3','4'])
if(rrr[0] eq (-1)) then answ1='4'
if(answ1 eq '1') then flip_ver_sw=1
if(answ1 eq '2') then flip_hor_sw=1
if(answ1 eq '3') then begin
flip_ver_sw=1
flip_hor_sw=1
endif
endif
print,flnm+'.'+flext+' ---> '+strupcase(flnm)+'.fits'
if((flip_ver_sw eq 1) and (flip_hor_sw eq 0)) then new_img_fts=reverse(img_fts,2)
if((flip_ver_sw eq 0) and (flip_hor_sw eq 1)) then new_img_fts=reverse(img_fts,1)
if((flip_ver_sw eq 1) and (flip_hor_sw eq 1)) then new_img_fts=reverse(reverse(img_fts,1),2)
if((flip_ver_sw+flip_hor_sw) gt 0) then begin
if(i eq 0) then begin
window,1,title='FITS image',xs=xwinsize,ys=ywinsize
tvscl,congrid(new_img_fts,xwinsize,ywinsize)
answ2=' '
print,' '
print,'Are you satisfied? (y/N)'
read,answ2
print,' '
print,' '
answ2=strupcase(answ2)
endif else begin
answ2='Y'
endelse
if(answ2 eq 'Y') then img_fts=temporary(new_img_fts) else goto,aglll01
endif
; fits_write,fldir_out+strupcase(flnm)+'.fits',img_fts,hdr_fts
outhdr=hdr_fts
fits_open,fldir_out+strupcase(flnm)+'.fits',fcbout,/write
sxaddpar,outhdr,'ORIGIN','bmp2fits_v2.0'
sxaddpar,outhdr,'BSCALE',1.0d0
sxaddpar,outhdr,'BZERO',0.0d0
sxaddpar,outhdr,'DATAMIN',min(double(img_fts))
sxaddpar,outhdr,'DATAMAX',max(double(img_fts))
fits_write,fcbout,img_fts,outhdr
fits_close,fcbout
;
file_delete,fldir_out+'tmp.fits'
endfor
print,' '
print,'Done.'
print,' '
print,' '
print,' '
;
;
end