;############################################################################# ;# # ;# OFFICIAL DISCLAIMER # ;# ================================================================ # ;# this file contains explicit source code, everyone who finds # ;# frontal open source code to be offensive or objectionable, or # ;# is not old enough or otherwise legally not entitled to view such # ;# stuff should delete this file imediately # ;# # ;############################################################################# ;+ ; NAME: ; LOAD_SLC ; ; PURPOSE: ; ; This Routine loads an Single Look Complex SAR data set (SLC) ; 4 different data formats are supported: ; - Andreas 'Anderl' Reigber's: rarr.pro/sarr.pro ; - Rolf Schreiber's format: 2 LONG values as header ; - Gunther Jaeger's READ_ARRAY.pro/SAVE_ARRAY.pro format ; - raw 32 bit complex data without header ; ; AUTHOR: ; ; Martin Hellmann paddy@gmx.co.uk ; ; CATEGORY: ; ; I/O Routines, SAR data ; ; CALLING SEQUENCE: ; ; LOAD_SLC,slc ; ; INPUTS: ; ; None. ; ; KEYWORD PARAMETERS: ; ; None. ; ; OUTPUTS: ; None. ; ; COMMON BLOCKS: ; None. ; ; SIDE EFFECTS: ; ; zu Risiken und Nebenwirkunegn lesen sie die Packungsbeilage ; und fragen sie Ihren Arzt oder Apotheker ; ; RESTRICTIONS: ; ; reads currently data sets up to 32000 by 32000 pixel ; if you want/need more - and have this much memory;) - you have ; to change MaxTestBlock in pro TestBoxCD. ; the EMISAR data (as well as other data types not mentioned here) ; are not supported. If you want to read them transform them in ; complex arrays (E.g. for EMISAR data use the util.c/UTIL.EXE ; routine delivered with the data) or write your own progs ;) ; ; PROCEDURE: ; ; 1. compile the programme - the output should look like this ; ; IDL> .r load_slc2 ; % Compiled module: TESTBLOCKNUMBER_INPUT. ; % Compiled module: TEXTBOXCB. ; % Compiled module: READDATATYPE. ; % Compiled module: READRGPTS. ; % Compiled module: READDAZPTS. ; % Compiled module: RARR. ; % Compiled module: SARR. ; % Compiled module: READ_ARRAY. ; % Compiled module: SAVE_ARRAY. ; % Compiled module: LOAD_SLC. ; ; 2. run the programm or call it from within your programm ; ; IDL> LOAD_SLC,arrayname ; ; ; 3. select data format and - if applicable x- and y dimensions ; ; 4. the data set should now be accessible as 'arrayname' ; ; EXAMPLE: ; ; LOAD_SLC, img1 ; window,1,title='magnitude image',xsize=512,ysize=512 ; tv,congrid(abs(img1),512,512) ; ; MODIFICATION HISTORY: ; ; Written by: Martin Hellmann, 15 May 2001. ; GUIs included 24 May 2001 ;- ;########################################################################### ; ; LICENSE ; ; This software is provided "as-is", without any express or ; implied warranty. In no event will the authors be held liable ; for any damages arising from the use of this software. ; ; Permission is granted to anyone to use this software for any ; purpose, including commercial applications, and to alter it and ; redistribute it freely, subject to the following restrictions: ; ; 1. The origin of this software must not be misrepresented; you must ; not claim you wrote the original software. If you use this software ; in a product, an acknowledgment in the product documentation ; would be appreciated, but is not required. ; ; 2. Altered source versions must be plainly marked as such, and must ; not be misrepresented as being the original software. ; ; 3. This notice may not be removed or altered from any source distribution. ; ; For more information on Open Source Software, visit the Open Source ; web site: http://www.opensource.org. ; ;------------------------------------------------------------------ ; This software has been released under the terms of the GNU Public ; license. See http://www.gnu.org/copyleft/gpl.html for details. ;------------------------------------------------------------------ ;############################################################################# ;# # ;# LOAD_SLC # ;# # ;############################################################################# ;############################################################################# ;# # ;# This Routine loads an Single Look Complex SAR data set (SLC) # ;# 4 different data formats are supported: # ;# - Andreas 'Anderl' Reigber's: rarr.pro/sarr.pro # ;# - Rolf Schreiber's format: 2 LONG values as header # ;# - Gunther Jaeger's READ_ARRAY.pro/SAVE_ARRAY.pro format # ;# - raw 32 bit complex data without header # ;# # ;# CALLING SEQUENCE: loadslc,slc # ;# # ;############################################################################# ;# # ;# This software has been released under the terms of the GNU Public # ;# license. See http://www.gnu.org/copyleft/gpl.html for details. # ;# # ;############################################################################# ;# Version 1.0 / 16.05.2001 Last Modification: 23.05.2001 # ;# # ;# M.Hellmann # ;############################################################################# ;============================================================================= ;==================== The reading and saving routines for ================ ;==================== Anderl's and Gunther's Formats ================ ;==================== uncomment and/ or save in seperate file ================ ;==================== if you don't have them already ================ ;============================================================================= ; ;------------------------------------------------------------------------------ ; ;------------------------------------------------------------------------------ ; ; Autor: Andreas Reigber ; ; Datum: 1.4.1998 ; ; ; ; Write a variable to a file. Any dimensions and type. ; ; ; ; Aufruf: sarr,filename,array ; ; Keywords: INFO - Comment (default = "unknown content") ; ; JOAO - my old format (2*long, then always floatarray) ; ; NOXDR - dont use /XDR format ; ; HEADER- only save header (only if not /JOAO) ; ; in array you get back open LUN ; ; GZIP - compress with gzip komprimiert, dont put .gz at the end ; ; ; ;------------------------------------------------------------------------------ ; ;------------------------------------------------------------------------------ ; ;------------------------------------------------------------------ ; ; This software has been released under the terms of the GNU Public ; ; license. See http://www.gnu.org/copyleft/gpl.html for details. ; ;------------------------------------------------------------------ ; ; ; pro sarr,file,bild,INFO=info,JOAO=joao,NOXDR=noxdr,HEADER=header,GZIP=gzip ; on_error,2 ; ; if keyword_set(noxdr) then xflag=0 else xflag=1 ; ; if not keyword_set(joao) then begin ; ; if not keyword_set(info) then info = "unknown content" ; leng = strlen(info) ; info = byte(info) ; if leng lt 80 then info = [info,bytarr(80-leng)+32b] $ ; else info = info[0:79] ; ; s=size(bild) ; s=s[0:s[0]+1] ; if keyword_set(header) then begin ; openw,ddd,file,/get_lun,xdr=xflag ; writeu,ddd,long(header) ; writeu,ddd,info ; bild = ddd ; endif else begin ; openw,ddd,file,/get_lun,xdr=xflag ; writeu,ddd,s ; writeu,ddd,info ; writeu,ddd,bild ; free_lun,ddd ; if keyword_set(gzip) then spawn,'gzip --fast '+file ; endelse ; ; endif else begin ; ; if keyword_set(info) then print,"Joao-Format kennt kein Infostring" ; openw,ddd,file,/get_lun,xdr=xflag ; writeu,ddd,long((size(bild))[1]) ; writeu,ddd,long((size(bild))[2]) ; writeu,ddd,bild ; free_lun,ddd ; ; endelse ; ; ; ; end ; ; ;------------------------------------------------------------------------------ ; ;------------------------------------------------------------------------------ ; ; Autor: Andreas Reigber ; ; Datum: 1.4.1998 ; ; ; ; read an array written by sarr ; ; ; ; Aufruf: rarr,filename,array ; ; Keywords: INFO - here you find the comment (Default = "unknown content") ; ; JOAO - my old format (2*long,then always floatarray - bad) ; ; NOXDR - do not use /XDR ; ; HEADER- read only header (if not /JOAO) ; ; in array you get the open LUN. ; ; BLOCK - read only this block of the data [X1,Y1,DX,DY] ; ; GZIP - uncompress with gunzip, dont put .gz at the end ; ; ; ;------------------------------------------------------------------------------ ; ;------------------------------------------------------------------ ; ; This software has been released under the terms of the GNU Public ; ; license. See http://www.gnu.org/copyleft/gpl.html for details. ; ;------------------------------------------------------------------ ; ; ; pro rarr,file,bild,INFO=info,JOAO=joao,NOXDR=noxdr,HEADER=header,BLOCK=block,GZIP=gzip ; on_error,2 ; ; ; Unzulaessige KEYWORD-Kombinationen ; if keyword_set(joao) and keyword_set(block) then begin ; print," Kombination /JOAO und /BLOCK nicht implementiert" ; return ; endif ; if keyword_set(header) and keyword_set(block) then begin ; print," Kombination /HEADER und /BLOCK ist Bloedsinn" ; return ; endif ; if keyword_set(header) and keyword_set(joao) then begin ; print," Kombination /HEADER und /JOAO nicht implementiert" ; return ; endif ; if keyword_set(info) and keyword_set(joao) then begin ; print,"Joao-Format kennt kein Infostring" ; return ; endif ; ; ; if keyword_set(noxdr) then xflag=0 else xflag=1 ; ; if not keyword_set(joao) then begin ; if keyword_set(gzip) then begin ; datstr = floor((randomu(seed,1))[0]*1e6) ; datstr = strcompress(datstr,/remove) ; spawn,'gunzip -c '+file+'.gz > /tmp/sarr'+datstr ; file = '/tmp/sarr'+datstr ; endif ; ; dim = 0l ; var = 0l ; info = bytarr(80) ; openr,ddd,file,/get_lun,xdr=xflag ; readu,ddd,dim ; siz=lonarr(dim) ; readu,ddd,siz ; readu,ddd,var ; readu,ddd,info ; info = strtrim(string(info)) ; ; if keyword_set(header) then begin ; bild = ddd ; header = [dim,siz,var] ; endif else begin ; if keyword_set(block) then begin ; case var of ; 4: bits = 4 ; 6: bits = 8 ; else: begin ; print,'Blocklesen nur bei FLOAT und COMPLEX' ; return ; end ; endcase ; point_lun,-ddd,pos ; point_lun,ddd,pos+block[1]*siz[0]*bits ; siz = [siz[0],block[3]] ; endif ; case var of ; 1: bild=make_array(/byte,dimension=siz) ; 2: bild=make_array(/int,dimension=siz) ; 3: bild=make_array(/long,dimension=siz) ; 4: bild=make_array(/float,dimension=siz) ; 5: bild=make_array(/double,dimension=siz) ; 6: bild=make_array(/complex,dimension=siz) ; 9: bild=make_array(/dcomplex,dimension=siz) ; else: begin ; print,'Arraytyp nicht erkannt (Falsches Format ??)' ; return ; end ; endcase ; readu,ddd,bild ; free_lun,ddd ; if keyword_set(gzip) then spawn,'rm '+file ; if keyword_set(block) then bild = bild[block[0]:block[0]+block[2]-1,*] ; endelse ; Header oder alles einlesen ; ; endif else begin ; Joao-Format ; ; sizx = 0l ; sizy = 0l ; openr,ddd,file,/get_lun,xdr=xflag ; readu,ddd,sizx ; readu,ddd,sizy ; bild=fltarr(sizx,sizy) ; readu,ddd,bild ; free_lun,ddd ; ; endelse ; Joao-Format ; end ; ; PRO save_array,array,filename ; ; ;SAVE_ARRAY saves any array up to 6 dimensions ; ;includes a header containing all informations ; ;about type and size of array ; ; ;CALLING SEQUENCE: ; ;SAVE_ARRAY,array,filename ; ; ; ;KEYWORD ; ;FILENAME: STRING, that contain the NAME array should be saved ; ;IF filename is not defined 'array.dat' is used ; ; IF KEYWORD_SET(filename) THEN BEGIN ; filename=filename ; ENDIF ELSE BEGIN ; filename='array.dat' ; ENDELSE ; ; arraySize=SIZE(array) ; ; OPENW,/XDR,unit,filename,/GET_LUN ; WRITEU,unit,arraySize ; WRITEU,unit,array ; FREE_LUN,unit ; ; END ; ; ; PRO read_array,array,filename ; ; ;READ_ARRAY reads any array up to 6 dimensions ; ;without needing any dimensions input ; ;Assumption is that array was saved with ; ;SAVE_ARRAY ; ; ; ;CALLING SEQUENCE: ; ;READ_ARRAY,array,filename ; ; ; ;KEYWORD ; ;FILENAME: STRING, that contain the NAME array should be saved ; ;IF filename is not defined 'array.dat' is used ; ; ; ; IF KEYWORD_SET(filename) THEN BEGIN ; filename=filename ; ENDIF ELSE BEGIN ; filename='array.dat' ; ENDELSE ; ; dim=LONG(1) & cols=LONG(1) & rows=LONG(1) & depth=LONG(1) ; dim4=LONG(1) & dim5=LONG(1) & dim6=LONG(1) & type=LONG(1) ; elements=LONG(1) ; ; OPENR,/XDR,unit,filename,/GET_LUN ; READU,unit,dim ; ; IF dim EQ 0 THEN PRINT,'Array is undefined' ; IF dim GE 1 THEN READU,unit,cols ; IF dim GE 2 THEN READU,unit,rows ; IF dim GE 3 THEN READU,unit,depth ; IF dim GE 4 THEN READU,unit,dim4 ; IF dim GE 5 THEN READU,unit,dim5 ; IF dim GE 6 THEN READU,unit,dim6 ; IF dim GE 7 THEN PRINT,'You want read to much dimensions, write YOUR own Program !!!' ; ; READU,unit,type ; READU,unit,elements ; ; IF type EQ 0 THEN PRINT,'Array is undefined' ; IF type EQ 1 THEN array=BYTARR(cols,rows,depth,dim4,dim5,dim6) ; IF type EQ 2 THEN array=INTARR(cols,rows,depth,dim4,dim5,dim6) ; IF type EQ 3 THEN array=LONARR(cols,rows,depth,dim4,dim5,dim6) ; IF type EQ 4 THEN array=FLTARR(cols,rows,depth,dim4,dim5,dim6) ; IF type EQ 5 THEN array=DBLARR(cols,rows,depth,dim4,dim5,dim6) ; IF type EQ 6 THEN array=COMPLEXARR(cols,rows,depth,dim4,dim5,dim6) ; IF type EQ 7 THEN array=STRARR(cols,rows,depth,dim4,dim5,dim6) ; IF type EQ 8 THEN array=CREATE_STRUCT({array},cols) ; IF type EQ 9 THEN array=DCOMPLEXARR(cols,rows,depth,dim4,dim5,dim6) ; ; READU,unit,array ; ; FREE_LUN,unit ; END ; ; ;============================================================================ ;========================= the widget/GUI routines ======================== ;============================================================================ ; PRO TestBlockNumber_Input,Value TestBlockNumber = Value ;Print,TestBlockNumber END PRO TextBoxCB, Event Common ReturnValue, in_value Widget_Control,Event.ID, Get_Value= Value Value = FIX(Value[0]) MaxTestBlock = 32000 If (Value GE 1) AND (Value LE MaxTestBlock) Then Begin ans = Dialog_Message('Is this Number Correct?', /Question) If ans EQ 'Yes' Then Begin TestBlockNumber_Input, Value in_value = Value EndIf EndIf Else Widget_Control,Event.id,Set_Value='2' Widget_Control,event.top,/destroy END PRO readdatatype, in_value tlb = Widget_Base(Title = 'Select',/Column) Label = Widget_Label(tlb,Value='data type') TextBox = Widget_Text(tlb,Value='2',/Editable,Event_Pro='TextBoxCB') Widget_Control, tlb, /Realize xManager,'TestGUI',tlb END PRO readrgpts, in_value tlb = Widget_Base(Title = 'Input',/Column) Label = Widget_Label(tlb,Value='type No. of pix in Range') TextBox = Widget_Text(tlb,Value='2',/Editable,Event_Pro='TextBoxCB') Widget_Control, tlb, /Realize xManager,'TestGUI',tlb END PRO readdazpts, in_value tlb = Widget_Base(Title = 'Input',/Column) Label = Widget_Label(tlb,Value='type No. of pix in Range') TextBox = Widget_Text(tlb,Value='2',/Editable,Event_Pro='TextBoxCB') Widget_Control, tlb, /Realize xManager,'TestGUI',tlb END @rarr.pro ;anderls read and write routines available at nought.de @sarr.pro ;http://epsilon.nought.de/ @read_array.pro @save_array.pro pro load_slc,slc Common ReturnValue, in_value ;============================= select data sets ============================= name =$ DIALOG_PICKFILE(/read,/must_exist,$ path='./',$ title='select data set') ;============================= select data format ============================= print,'' print,'select data format: type 1 for Anderls (rarr.pro/sarr.pro) format,' print,'type 2 for Rolf Scheibers format (2 long values as header), type 3' print,'for Gunther Jaegers format READ_ARRAY/SAVE_ARRAY and type 4 for ' print,'for pure Complex arrays without header information [1/2/3/4]' print,'' in_value='' ;==============================data formats================================== ;============================================================================ ;========================= those who don't like widget ==================== ;========================= may comment in the following lines =============== ;============================================================================ ;; repeat begin ; read,in_value ; endrep until ((in_value eq '1') or (in_value eq '2') or $ ; (in_value eq '3') or (in_value eq '4')) ; ;============================================================================ ;===================== and comment out the READDATATYPE below =============== ;============================================================================ ;==============================data formats================================== Label1: READDATATYPE case in_value of '1': rarr,name,slc ;------ Anderl's Format ----------- '2': begin openr,u,name,xdr=1,/get_lun ;------ Rolf's Format ------------- header=lonarr(2) readu,u,header slc=complexarr(header[0],header[1]) readu,u,slc free_lun,u end '3': READ_ARRAY,slc,name ;------ Gunther's Format ------------- ;============================================================================ ;========================= those who don't like widget ==================== ;========================= may comment in the following lines =============== ;============================================================================ ; ; '4': begin ; HELL: ; print,'type no. of pixel in range (x-dimension of the array)' ; rg_pix=1l ; read,rg_pix ; print,'type no. of pixel in azimuth (y-dimension of the array)' ; az_pix=1l ; read,az_pix ; ; print,'the dimenions are' ; print,'No. pixel in azimuth = ',+ Strcompress(rg_pix) ; print,'No. pixel in azimuth = ',+ Strcompress(az_pix) ; print,'is this correct ? [Y/N]' ; confrm='' ; repeat begin ; read,confrm ; endrep until ((confrm eq 'n') or (confrm eq 'N') $ ; or (confrm eq 'y') or (confrm eq 'Y')) ; if ((confrm eq 'n') or (confrm eq 'N')) then goto, hell ; openr,u,name,xdr=1,/get_lun ; slc=complexarr(rg_pix,az_pix) ; readu,u,slc ; free_lun,u ;============================================================================ ;========================= and comment in the following lines =============== ;============================================================================ '4': begin print,'type no. of pixel in range (x-dimension of the array)' readrgpts rg_pix=in_value print,'type no. of pixel in azimuth (y-dimension of the array)' readdazpts az_pix=in_value print,'the dimenions are' print,'No. pixel in azimuth = ',+ Strcompress(rg_pix) print,'No. pixel in azimuth = ',+ Strcompress(az_pix) openr,u,name,xdr=1,/get_lun slc=complexarr(rg_pix,az_pix) readu,u,slc free_lun,u end ;============================================================================ ;=========================end of widget solution for option 4 =============== ;============================================================================ else: begin print, 'the cult of cuthullu does not allow to support this format!' goto, Label1 end ;No matches" endcase ;End of CASE statement. end