pro qSkyImage_Pick, state ;+ ; NAME: ; qSkyImage_Pick ; PURPOSE: ; Select data file with 3D matrices ; CATEGORY: ; Widget: qSkyImage ; CALLING SEQUENCE: ; qSkyImage_Pick, state ; INPUTS: ; OPTIONAL INPUT PARAMETERS: ; OUTPUTS: ; OPTIONAL OUTPUT PARAMETERS: ; CALLS: ; SetFileSpec, GetFileSpec, vu_Read, vu_Read_B, bin_read, AngleRange ; qSkyImage_AddData, qSkyImage_List, CarringtonT, NewcombSun, CvSky, TimeString ; COMMON BLOCKS: ; SIDE EFFECTS: ; RESTRICTIONS: ; PROCEDURE: ; MODIFICATION HISTORY: ; JUN-2000, Paul Hick (UCSD/CASS; pphick@ucsd.edu) ;- on_error, 2 ; On error, return to caller COMPILE_OPT hidden ; Pick up file filter from widget widget_control, state.wid_filter, get_value=filter filter = filter[0] ; Check for the presence of wildcards wildcard = strpos(filter, '*') ne -1 or $ strpos(filter, '?') ne -1 or $ strpos(filter, '%') ne -1 ; Use pickfile dialog if a wildcard was found; otherwise just try to read the file if wildcard then begin ; Select single file SetFileSpec, filter file = dialog_pickfile( $ path = GetFileSpec(upto='directory'), $ filter = GetFileSpec(from='name',upto='type'), $ group = state.wid_matrix, title='Select image file') file = file[0] endif else $ file = filter status = file ne '' if status then begin widget_control, state.wid_tmatrix, get_uvalue=format SetFileSpec, file type = GetFileSpec(from='type', upto='type') name = GetFileSpec(from='name', upto='name') OK = 0B catch, ierror if ierror eq 0 then begin if strlowcase(strmid(name,0,3)) eq 't3d' then begin OK = vu_Read(file, vh3d=f0, dh3d=f1, xcrange=xcrange, radii=radii) if OK then add_list = string(xcrange[0], format=format)+' '+['velocity','density'] endif else if strlowcase(strmid(name,0,3)) eq 'm3d' then begin OK = vu_Read_B(file, bss=bss, b3d=f2, xcrange=xcrange, radii=radii) if OK then begin f0 = reform(f2[0,*,*,*]) f1 = reform(f2[1,*,*,*]) f2 = reform(f2[2,*,*,*]) add_list=string(xcrange[0], format=format)+' '+['Brad','Btang','Bnorm'] endif endif else if strlowcase(type) eq '.pph' then begin OK = bin_read(file, f3d, trailer=trailer) OK = n_elements( size(f0, /dim) ) eq 3 if OK then add_list='data' endif endif catch, /cancel if OK then begin qSkyImage_AddData, state, f0, f1, f2, add_list=add_list qSkyImage_List, state info = file if n_elements(xcrange) ne 0 then begin widget_control, state.wid_tlabel , get_uvalue=wid_unit ; XCrange[0] is the starting point of the matrix (in modified Carrington variable) ; We take the mean of XCrange[0] and XCrange[1] as the display time (i.e. midway ; through the rotation. The display time is also used to calculate the ; viewing location and direction. tmatrix = xcrange[0] tdisplay = mean(xcrange) tloc = tdisplay case wid_unit of state.wid_uttime : begin tmatrix = TimeString(CarringtonT(tmatrix ), /ymd) tdisplay = TimeString(CarringtonT(tdisplay), /ymd) end state.wid_rotation: begin tmatrix = string(tmatrix , format=format) tdisplay = string(tdisplay, format=format) end endcase widget_control, state.wid_tmatrix , set_value=tmatrix widget_control, state.wid_tdisplay, set_value=tdisplay ; The location of Earth at the display time is taken as the viewing location. ; The viewing direction is towards the Sun. tloc = CarringtonT(tloc) loc = NewcombSun (tloc, /degrees, /heliocentric) widget_control, state.wid_clabel, get_uvalue=wid_unit if wid_unit eq state.wid_heliographic then loc = CvSky(tloc, fromecliptic=loc, /toheliographic, /deg) widget_control, state.wid_earth[0], set_value=loc[0] widget_control, state.wid_earth[1], set_value=loc[1] widget_control, state.wid_earth[2], set_value=loc[2] widget_control, state.wid_loc[0], set_value=loc[0] widget_control, state.wid_loc[1], set_value=loc[1] widget_control, state.wid_loc[2], set_value=loc[2] widget_control, state.wid_dir[0], set_value=AngleRange(loc[0]+180, /deg) widget_control, state.wid_dir[1], set_value=-loc[1] info = [info,'', 'Carrington range: '+string(xcrange[0], format=format)+ $ ' - '+string(xcrange[1], format=format)] endif if n_elements(radii) ne 0 then begin rmin = min(radii, max=rmax) widget_control, state.wid_rmatrix[0], set_value=rmin widget_control, state.wid_rmatrix[1], set_value=rmax info = [info, 'Radial range (AU): '+string(rmin, format=format)+string(rmax, format=format)] endif info = strjoin(info+string([13b,10b])) widget_control, state.wid_info, set_uvalue=info endif endif return & end