function varargout = ncdfView(varargin) % ncdfView is a simple, very alpha (bits probably don't work!) quickview tool for % visualising geophysical data in MatLAB. I've tested it pretty much only % with ECMWF ERA and UKMO NAE data; it may/should work with other data sources, but don't be % surprised if it doesn't. % % You'll need the mexnc libraries to do anything at all, and m_map if you % want to make use of any of the mapping routines. % % Last Modified by GUIDE v2.5 14-Jul-2010 16:50:04 % Begin initialization code - DO NOT EDIT gui_Singleton = 1; gui_State = struct('gui_Name', mfilename, ... 'gui_Singleton', gui_Singleton, ... 'gui_OpeningFcn', @ncdfView_OpeningFcn, ... 'gui_OutputFcn', @ncdfView_OutputFcn, ... 'gui_LayoutFcn', [] , ... 'gui_Callback', []); if nargin && ischar(varargin{1}) gui_State.gui_Callback = str2func(varargin{1}); end if nargout [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:}); else gui_mainfcn(gui_State, varargin{:}); end % End initialization code - DO NOT EDIT % --- Executes just before ncdfView is made visible. function ncdfView_OpeningFcn(hObject, eventdata, handles, varargin) % This function has no output args, see OutputFcn. % hObject handle to figure % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % varargin command line arguments to ncdfView (see VARARGIN) thisVersion = 0.02; % Choose default command line output for ncdfView handles.output = hObject; % Update handles structure guidata(hObject, handles); % UIWAIT makes ncdfView wait for user response (see UIRESUME) % uiwait(handles.ncdfView); checkVersion(thisVersion); % --- Outputs from this function are returned to the command line. function varargout = ncdfView_OutputFcn(hObject, eventdata, handles) % varargout cell array for returning output args (see VARARGOUT); % hObject handle to figure % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Get default command line output from handles structure varargout{1} = handles.output; % --- Executes on button press in loadButton. % function loadButton_Callback(hObject, eventdata, handles) % % hObject handle to loadButton (see GCBO) % % eventdata reserved - to be defined in a future version of MATLAB % % handles structure with handles and user data (see GUIDATA) % handles.file1 = get(handles.fileChooser1,'String'); % handles.file2 = get(handles.fileChooser2,'String'); % % [ncid, status] = mexnc('open', handles.file1); % [nvars, status] = mexnc('inq_nvars', ncid); % % disp(sprintf('Read NetCDF file %s', handles.file1)); % disp(sprintf('I''m counting %d variables...', nvars)); % names = {}; % for(i = 0:nvars-1) % [name, type, ndims, dimids, natts, status] = mexnc('inq_var', ncid, i); % names = [names cellstr(name)]; % end % [ndims, status] = mexnc('inq_ndims', ncid); % disp(['...and ' num2str(ndims) ' dimensions.']); % % dimnames = {}; % dimlengths = []; % for(i = 0:ndims-1) % [dimname, dimlength, status] = mexnc('inq_dim',ncid,i); % dimnames = [dimnames cellstr(dimname)]; % dimlengths = [dimlengths dimlength]; % end % % handles.varNames = names; % handles.dimNames = dimnames; % handles.dimLengths = dimlengths; % % handles.varNames % handles.dimNames % handles.dimLengths % % set(handles.variablesList,'String',names); % mexnc('close',ncid); % guidata(hObject,handles) % --- Executes on selection change in variablesList. function variablesList_Callback(hObject, eventdata, handles) % hObject handle to variablesList (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: contents = get(hObject,'String') returns variablesList contents as cell array % contents{get(hObject,'Value')} returns selected item from variablesList % --- Executes during object creation, after setting all properties. function variablesList_CreateFcn(hObject, eventdata, handles) % hObject handle to variablesList (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: listbox controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end % --- Executes on selection change in fileList. function fileList_Callback(hObject, eventdata, handles) % hObject handle to fileList (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: contents = get(hObject,'String') returns fileList contents as cell array % contents{get(hObject,'Value')} returns selected item from fileList % --- Executes during object creation, after setting all properties. function fileList_CreateFcn(hObject, eventdata, handles) % hObject handle to fileList (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: listbox controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end % --- Executes on button press in addFilesButton. function addFilesButton_Callback(hObject, eventdata, handles) % hObject handle to addFilesButton (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Show a user interface to select files. Multiple file selection is % currently not allowed, although this is a planned feature. [files, paths] = uigetfile({'*.nc;*.cdf;', 'NetCDF files (*.nc, *.cdf)';'*.*','All Files (*.*)'}, 'Load files...','multiSelect','on'); paths % If only one file is selected then it is retuned as a string rather than a % cell. Here we make sure we are always dealing with a cell. if(~iscell(files)) files = cellstr(files); paths = cellstr(paths); end paths = cellstr(paths); % Save file metadata into the handles structure handles.files = files; handles.numFiles = length(files); handles.paths = paths; % Eventually we're going to have to loop over files to check what is in % each file and make sure these are compatible with each other. for(nFile=1:1) %% Dummy for when we can deal with files with different dimensions/variables % Get the current filename and path of the current file, as strings file = char(files(nFile)) path = char(paths(nFile)) % Open the netCDF file, inquire about the number of variables. [ncid, status] = mexnc('open', [path file]); [nvars, status] = mexnc('inq_nvars', ncid); % Report the number of variables in the netCDF file. updateStatus(sprintf('Read NetCDF file %s', file),0); updateStatus(sprintf(' -> I''m counting %d variables...', nvars),0); % Loop over all of the variables and store the name of each variable of % into an array of cells named 'names' names = {}; for(i = 0:nvars-1) [name, type, ndims, dimids, natts, status] = mexnc('inq_var', ncid, i); names = [names cellstr(name)]; end % Find and report the number of dimensions in the netCDF file [ndims, status] = mexnc('inq_ndims', ncid); updateStatus([' -> ...with ' num2str(ndims) ' dimensions...'],0); % Loop over all of the dimensions and record the names and lengths od % these dimensions dimnames = {}; dimlengths = []; for(i = 0:ndims-1) [dimname, dimlength, status] = mexnc('inq_dim',ncid,i); dimnames = [dimnames cellstr(dimname)]; dimlengths = [dimlengths dimlength]; end updateStatus([' -> ...of length [' num2str(dimlengths) ']'],0); % Save variable and dimension info into the handles structure. handles.varNames = names; handles.dimNames = dimnames; handles.dimLengths = dimlengths end % Close the netCDF file we've been working on % TODO: shouldn't this be inside the loop above?? mexnc('close',ncid); % Update the gui-handles structure. guidata(hObject,handles); % Set drop-down menus and suchlike to display the variables and dimensons % assiciated with the netCDF file(s) setGeneralMenus(handles); % Report that we're done. msg = []; for(i=1:length(files)) msg = [msg char(files(i)) ' ']; end updateStatus(['Loaded file(s) ' msg],0); % --- Executes on selection change in zonalMenu. function zonalMenu_Callback(hObject, eventdata, handles) % hObject handle to zonalMenu (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: contents = get(hObject,'String') returns zonalMenu contents as cell array % contents{get(hObject,'Value')} returns selected item from zonalMenu % --- Executes during object creation, after setting all properties. function zonalMenu_CreateFcn(hObject, eventdata, handles) % hObject handle to zonalMenu (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: popupmenu controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end % --- Executes on selection change in meridionalMenu. function meridionalMenu_Callback(hObject, eventdata, handles) % hObject handle to meridionalMenu (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: contents = get(hObject,'String') returns meridionalMenu contents as cell array % contents{get(hObject,'Value')} returns selected item from meridionalMenu % --- Executes during object creation, after setting all properties. function meridionalMenu_CreateFcn(hObject, eventdata, handles) % hObject handle to meridionalMenu (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: popupmenu controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end % --- Executes on selection change in verticalMenu. function verticalMenu_Callback(hObject, eventdata, handles) % hObject handle to verticalMenu (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: contents = get(hObject,'String') returns verticalMenu contents as cell array % contents{get(hObject,'Value')} returns selected item from verticalMenu % --- Executes during object creation, after setting all properties. function verticalMenu_CreateFcn(hObject, eventdata, handles) % hObject handle to verticalMenu (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: popupmenu controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end % --- Executes on selection change in timeMenu. function timeMenu_Callback(hObject, eventdata, handles) % hObject handle to timeMenu (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: contents = get(hObject,'String') returns timeMenu contents as cell array % contents{get(hObject,'Value')} returns selected item from timeMenu % --- Executes during object creation, after setting all properties. function timeMenu_CreateFcn(hObject, eventdata, handles) % hObject handle to timeMenu (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: popupmenu controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end % --- Executes on button press in lonCheckbox. function lonCheckbox_Callback(hObject, eventdata, handles) % hObject handle to lonCheckbox (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hint: get(hObject,'Value') returns toggle state of lonCheckbox if(get(hObject,'value')) set(handles.latCheckbox,'value',1); else set(handles.latCheckbox,'value',0); end % --- Executes on button press in latCheckbox. function latCheckbox_Callback(hObject, eventdata, handles) % hObject handle to latCheckbox (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hint: get(hObject,'Value') returns toggle state of latCheckbox if(get(hObject,'value')) set(handles.lonCheckbox,'value',1); else set(handles.lonCheckbox,'value',0); end %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Non-callback functions %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function setGeneralMenus(handles); set(handles.variablesList,'String',handles.varNames); set(handles.fileList,'String',handles.files); set(handles.zonalMenu,'String',handles.dimNames); set(handles.meridionalMenu,'String',handles.dimNames); set(handles.verticalMenu,'String',handles.dimNames); set(handles.timeMenu,'String',handles.dimNames); setDimensionMenus(handles); function setDimensionMenus(handles) dims = handles.dimNames for(i = 1:length(dims)) if(strcmp(char(dims(i)),'Longitude')) set(handles.zonalMenu,'value',i) setLatLonBoxes(handles,1); end if(strcmp(char(dims(i)),'longitude')) set(handles.zonalMenu,'value',i) setLatLonBoxes(handles,1); end if(strcmp(char(dims(i)),'Lon')) set(handles.zonalMenu,'value',i) setLatLonBoxes(handles,1); end if(strcmp(char(dims(i)),'lon')) set(handles.zonalMenu,'value',i) setLatLonBoxes(handles,1); end if(strcmp(char(dims(i)),'x')) set(handles.zonalMenu,'value',i) setLatLonBoxes(handles,0); end if(strcmp(char(dims(i)),'X')) set(handles.zonalMenu,'value',i) setLatLonBoxes(handles,0); end if(strcmp(char(dims(i)),'Latitude')) set(handles.meridionalMenu,'value',i) setLatLonBoxes(handles,1); end if(strcmp(char(dims(i)),'latitude')) set(handles.meridionalMenu,'value',i) setLatLonBoxes(handles,1); end if(strcmp(char(dims(i)),'Lat')) set(handles.meridionalMenu,'value',i) setLatLonBoxes(handles,1); end if(strcmp(char(dims(i)),'lat')) set(handles.meridionalMenu,'value',i) setLatLonBoxes(handles,1); end if(strcmp(char(dims(i)),'y')) set(handles.meridionalMenu,'value',i) setLatLonBoxes(handles,0); end if(strcmp(char(dims(i)),'Y')) set(handles.meridionalMenu,'value',i) setLatLonBoxes(handles,0); end if(strcmp(char(dims(i)),'z')) set(handles.verticalMenu,'value',i) end if(strcmp(char(dims(i)),'Z')) set(handles.verticalMenu,'value',i) end if(strcmp(char(dims(i)),'height')) set(handles.verticalMenu,'value',i) end if(strcmp(char(dims(i)),'ht')) set(handles.verticalMenu,'value',i) end if(strcmp(char(dims(i)),'h')) set(handles.verticalMenu,'value',i) end if(strcmp(char(dims(i)),'Height')) set(handles.verticalMenu,'value',i) end if(strcmp(char(dims(i)),'surface')) set(handles.verticalMenu,'value',i) end if(strcmp(char(dims(i)),'Surface')) set(handles.verticalMenu,'value',i) end if(strcmp(char(dims(i)),'level')) set(handles.verticalMenu,'value',i) end if(strcmp(char(dims(i)),'Level')) set(handles.verticalMenu,'value',i) end if(strcmp(char(dims(i)),'P')) set(handles.verticalMenu,'value',i) end if(strcmp(char(dims(i)),'p')) set(handles.verticalMenu,'value',i) end if(strcmp(char(dims(i)),'t')) set(handles.timeMenu,'value',i) end if(strcmp(char(dims(i)),'time')) set(handles.timeMenu,'value',i) end if(strcmp(char(dims(i)),'Time')) set(handles.timeMenu,'value',i) end end % This sets the vertical level menu... strs = get(handles.verticalMenu,'String') vls = get(handles.verticalMenu,'Value') vvals = readnc([char(handles.paths) char(handles.files)],char(strs(vls))); %%was readnc set(handles.verticalLevelMenu,'String',num2str(vvals)); %-------------------------------------------------------------------------- function setLatLonBoxes(handles,val) set(handles.lonCheckbox,'value',val); set(handles.latCheckbox,'value',val); %-------------------------------------------------------------------------- function updateStatus(message,err) handles = guihandles(findobj('tag','messageList')); prev_str = get(handles.messageList,'String'); prev_str = [prev_str ;{message}]; set(handles.messageList,'String',prev_str,'Value',length(prev_str)); if(err) set(handles.messageList,'ForegroundColor','r'); else set(handles.messageList,'Foregroundcolor','k'); end pause(.1); %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % --- Executes on selection change in listbox4. function listbox4_Callback(hObject, eventdata, handles) % hObject handle to listbox4 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: contents = get(hObject,'String') returns listbox4 contents as cell array % contents{get(hObject,'Value')} returns selected item from listbox4 % --- Executes during object creation, after setting all properties. function listbox4_CreateFcn(hObject, eventdata, handles) % hObject handle to listbox4 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: listbox controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end % --- Executes on button press in aboutButton. % function aboutButton_Callback(hObject, eventdata, handles) % hObject handle to aboutButton (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % --- Executes on button press in controlButton. function controlButton_Callback(hObject, eventdata, handles) % hObject handle to controlButton (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % --- Executes on button press in addDirButton. function addDirButton_Callback(hObject, eventdata, handles) % hObject handle to addDirButton (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % --- Executes on selection change in projList. function projList_Callback(hObject, eventdata, handles) % hObject handle to projList (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: contents = get(hObject,'String') returns projList contents as cell array % contents{get(hObject,'Value')} returns selected item from projList % --- Executes during object creation, after setting all properties. function projList_CreateFcn(hObject, eventdata, handles) % hObject handle to projList (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: popupmenu controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end function latMaxBox_Callback(hObject, eventdata, handles) % hObject handle to latMaxBox (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: get(hObject,'String') returns contents of latMaxBox as text % str2double(get(hObject,'String')) returns contents of latMaxBox as a double % --- Executes during object creation, after setting all properties. function latMaxBox_CreateFcn(hObject, eventdata, handles) % hObject handle to latMaxBox (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end function edit7_Callback(hObject, eventdata, handles) % hObject handle to edit7 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: get(hObject,'String') returns contents of edit7 as text % str2double(get(hObject,'String')) returns contents of edit7 as a double % --- Executes during object creation, after setting all properties. function edit7_CreateFcn(hObject, eventdata, handles) % hObject handle to edit7 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end function edit8_Callback(hObject, eventdata, handles) % hObject handle to edit8 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: get(hObject,'String') returns contents of edit8 as text % str2double(get(hObject,'String')) returns contents of edit8 as a double % --- Executes during object creation, after setting all properties. function edit8_CreateFcn(hObject, eventdata, handles) % hObject handle to edit8 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end function edit9_Callback(hObject, eventdata, handles) % hObject handle to edit9 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: get(hObject,'String') returns contents of edit9 as text % str2double(get(hObject,'String')) returns contents of edit9 as a double % --- Executes during object creation, after setting all properties. function edit9_CreateFcn(hObject, eventdata, handles) % hObject handle to edit9 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end % --- Executes on button press in plotButton. function plotButton_Callback(hObject, eventdata, handles) % hObject handle to plotButton (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) errorFlag = 0; temp = get(handles.fileList,'Value'); file = [char(handles.paths(temp)) char(handles.files(temp))]; lat_min = str2double(get(handles.latMinBox,'String')); lat_max = str2double(get(handles.latMaxBox,'String')); lon_min = str2double(get(handles.lonMinBox,'String')); lon_max = str2double(get(handles.lonMaxBox,'String')); projVal = get(handles.projList,'Value'); projection = get(handles.projList,'String'); projection = char(projection(projVal)); m_proj(projection,'lats',[lat_min lat_max],'lons',[lon_min lon_max]); cmin = str2double(get(handles.cMinBox,'String')); cmax = str2double(get(handles.cMaxBox,'String')); animate = get(handles.animateBox,'Value'); tskip = str2double(get(handles.timeSkipArea,'String')); tstart = str2double(get(handles.timeStartArea,'String')); tlevs = str2double(get(handles.timeEndArea,'String')); cmapv = get(handles.colormapMenu,'Value'); cmap = get(handles.colormapMenu,'String'); cmap = char(cmap(cmapv)); if(isnan(tstart)) updateStatus('Error: Problem with time-level inputs!',1); return; end if(~animate) tlevs = tstart; tskip = 1; end dims = handles.dimNames; ncid = mexnc('open',file); dimLength = zeros(size(dims)); for(i = 0:length(dims)-1) dimLength(i+1) = mexnc('inq_dimlen',ncid,i); end % If we're not overplotting vectors on a shaded plot, create a new figure % and put its handle in the handles structure if(~get(handles.vecOverplotBox,'Value')) handles.dplot = figure; end guidata(hObject,handles); plot_type = get(handles.shadingMenu,'Value'); varVal = get(handles.variablesList,'Value'); var = get(handles.variablesList,'String'); var = (var(varVal)); %was char nv = length(var); if(plot_type==1 & nv > 1) updateStatus('Error: ''Shading'' option can only plot one variable!',1); return end if(plot_type==2 & nv~=2) updateStatus('Error: ''Shading/contour'' option requires two variables',1); return end if(plot_type==3 & nv~=2) updateStatus('Error: ''Vectors'' option requires two variables',1); return end if(plot_type==4 & nv~=2) updateStatus('Error: ''Shading (U,V)->Speed'' option requires two variables',1); return end if(plot_type == 3) vec_colour = get(handles.vecColourBox,'String'); vec_skip_x = str2double(get(handles.vecSkipXBox,'String')); vec_skip_y = str2double(get(handles.vecSkipYBox,'String')); if(isempty(vec_colour)) updateStatus(' -> Plotting BLACK vectors',0) vc = [0 0 0]; else eval(['vc = ' vec_colour ';']); end if(isempty(vec_skip_x) | isnan(vec_skip_x)); vec_skip_x = 1; end if(isempty(vec_skip_y) | isnan(vec_skip_y)); vec_skip_y = 1; end end %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % LOOPING DID START HERE!!!!!! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Find which dimension is the time/lon/lat dimension for(i=1:length(dims)) val = get(handles.timeMenu,'Value'); str = get(handles.timeMenu,'String'); str = str(val); if(strcmp(char(dims(i)),char(str))) timeDim = i; end val = get(handles.zonalMenu,'Value'); str = get(handles.zonalMenu,'String'); str = str(val); if(strcmp(char(dims(i)),char(str))) zonalDim = i; end val = get(handles.meridionalMenu,'Value'); str = get(handles.meridionalMenu,'String'); str = str(val); if(strcmp(char(dims(i)),char(str))) meridionalDim = i; end val = get(handles.verticalMenu,'Value'); str = get(handles.verticalMenu,'String'); str = str(val); if(strcmp(char(dims(i)),char(str))) verticalDim = i; end end %%%%%%%%%%% THIS STUF FHAS BEEN MOVED %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Get the names of the lat/lon dimensions... latVal = get(handles.meridionalMenu,'Value'); lat = get(handles.meridionalMenu,'String'); lat = char(lat(latVal)); lonVal = get(handles.zonalMenu,'Value'); lon = get(handles.zonalMenu,'String'); lon = char(lon(lonVal)); % Find out if the lat/lon dimensions can be read as variables latExists = 0; lonExists = 0; vars = handles.varNames; for(i = 1:length(vars)) if(strcmp(lat,char(vars(i)))) latExists = 1; end if(strcmp(lon,char(vars(i)))) lonExists = 1; end end % Read or create zonal/meridional coordinates if(latExists) lat = readnc(file,lat); else lat = 1:dimLength(meridionalDim); end if(lonExists) lon = readnc(file,lon); else lon = 1:dimLength(zonalDim); end lon_index = find(lon >= lon_min & lon <= lon_max); lat_index = find(lat >= lat_min & lat <= lat_max); % If we're using ukmo-nae data, we need to transform from the native x-y % coordinates to latitude/longitude ukmo_data = 0; if(strcmp(get(handles.ukmoNaeMenuOption,'checked'),'on')) ukmo_data = 1; updateStatus(' -> Converting UKMO from x-y to lon-lat',0); [lon lat] = ukmo(readnc(file,'x'),readnc(file,'y'),177.5,37.5); end %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % START ANIMATION LOOP! for(tlev = tstart:tskip:tlevs) start = zeros(size(dims)); finish = ones(size(dims)); start(timeDim) = tlev-1; start(verticalDim) = get(handles.verticalLevelMenu,'Value')-1; finish(zonalDim) = dimLength(zonalDim); finish(meridionalDim) = dimLength(meridionalDim); finish(timeDim) = 1; nvars = length(var); for(nv=1:nvars) varn = mexnc('inq_varid',ncid,char(var(nv))); field(:,:,nv) = mexnc('get_vara_double',ncid,varn,fliplr(start),fliplr(finish)); end %%%%%%%%%%%%%%%%%%%%%%%% STUFF WAS HERE %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % If the 'reverse variable order' box is checked, then swap the values of % field(:,:,1) and field(:,:,2) if(get(handles.RVOCheckbox,'Value')) RVOtemp = field(:,:,1); field(:,:,1) = field(:,:,2); field(:,:,2) = RVOtemp; end if(~min(size(lon) == size(field(:,:,1)))) [lon lat] = meshgrid(lon,lat); end if(~min(size(lon) == size(field(:,:,1)))) lon = lon'; lat = lat'; end if(plot_type == 3) try vec_scale = str2double(get(handles.vecScaleTextBox,'String')); if(isempty(vec_scale) | isnan(vec_scale)); updateStatus(' -> Not using any vector scaling...',0); vec_scale = 1; end catch updateStatus('Warning: problem setting vector scale, assuming unity',0); vec_scale = 1; end end if(get(handles.latCheckbox,'Value') | ukmo_data) if(plot_type==1) m_pcolor(lon,lat,double(field)),shading interp; elseif(plot_type==2) m_pcolor(lon,lat,double(squeeze(field(:,:,1)))),shading interp;hold on [cs h] = m_contour(lon,lat,double(squeeze(field(:,:,2))),15,'k');hold off clabel(cs,h,'manual'); elseif(plot_type==3) figure(handles.dplot); % Grid the plot hold on if(strcmp(get(handles.ukmoNaeMenuOption,'checked'),'on')) [lon lat field lon_index lat_index] = regridNAE(lon,lat,field,nvars,lon_min,lon_max,lat_min,lat_max); end m_grid('box','fancy','linestyle','none','fontsize',14); m_quiver(lon(lon_index(1:vec_skip_x:end),lat_index(1:vec_skip_y:end)),lat(lon_index(1:vec_skip_x:end),lat_index(1:vec_skip_y:end)),double(field(lon_index(1:vec_skip_x:end),lat_index(1:vec_skip_y:end),1)),double(field(lon_index(1:vec_skip_x:end),lat_index(1:vec_skip_y:end),2)),vec_scale,'color',vc); elseif(plot_type==4) m_pcolor(lon,lat,double(sqrt(field(:,:,1).^2+field(:,:,2).^2))),shading interp end if(get(handles.hiResCoastBox,'Value')) coast_command = 'm_gshhs_i'; else coast_command = 'm_coast'; end land_col = get(handles.landColourBox,'String'); % Get the colour for land outline or patch if(isempty(land_col)); land_col = '''k'''; end; % If this is empty default to black % Adjust the colour string, ensuring it either starts with a square % bracket or a quote, thus [r g b], colourName and 'colourName' are all % acceptable formats. if(land_col(1) ~= '''' & land_col(1) ~= '['); land_col = ['''' land_col '''']; end % Set coast arguments to either set colour of coastline or fill if(get(handles.patchCoastBox,'Value')) col_command = 'patch'; else col_command = 'color'; end % Overplot coastlines/land eval([coast_command '(' '''' col_command '''' ',' land_col ',''linewidth'',1.5)']); % Grid the plot if(plot_type ~= 3) hold on m_grid('box','fancy','linestyle','none','fontsize',14); hold off end else % i.e. we have x/y dims rather than lat/lon dims, so % just pcolor the data rather than mapping it pcolor(lon,lat,double(field)),shading interp end % Set the colour limits on the plot if(~isnan(cmin)&&~isnan(cmax)&&cmin= cmax) updateStatus('Error with colour axis limits! (cmin >= cmax)',1); errorFlag = 1; break; end try figure(handles.dplot); eval(['colormap ' cmap]); catch updateStatus(['Error setting colormap to ' cmap],1); errorFlag = 1; break; end pause(.25) end if(~errorFlag) updateStatus('Finished plotting!',0); else close(gcf); end mexnc('close',ncid); function latMinBox_Callback(hObject, eventdata, handles) % hObject handle to latMinBox (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: get(hObject,'String') returns contents of latMinBox as text % str2double(get(hObject,'String')) returns contents of latMinBox as a double % --- Executes during object creation, after setting all properties. function latMinBox_CreateFcn(hObject, eventdata, handles) % hObject handle to latMinBox (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end function lonMaxBox_Callback(hObject, eventdata, handles) % hObject handle to lonMaxBox (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: get(hObject,'String') returns contents of lonMaxBox as text % str2double(get(hObject,'String')) returns contents of lonMaxBox as a double % --- Executes during object creation, after setting all properties. function lonMaxBox_CreateFcn(hObject, eventdata, handles) % hObject handle to lonMaxBox (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end function lonMinBox_Callback(hObject, eventdata, handles) % hObject handle to lonMinBox (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: get(hObject,'String') returns contents of lonMinBox as text % str2double(get(hObject,'String')) returns contents of lonMinBox as a double % --- Executes during object creation, after setting all properties. function lonMinBox_CreateFcn(hObject, eventdata, handles) % hObject handle to lonMinBox (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end % --- Executes on selection change in shadingMenu. function shadingMenu_Callback(hObject, eventdata, handles) % hObject handle to shadingMenu (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: contents = get(hObject,'String') returns shadingMenu contents as cell array % contents{get(hObject,'Value')} returns selected item from shadingMenu % --- Executes during object creation, after setting all properties. function shadingMenu_CreateFcn(hObject, eventdata, handles) % hObject handle to shadingMenu (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: popupmenu controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end % -------------------------------------------------------------------- function FileMenu_Callback(hObject, eventdata, handles) % hObject handle to FileMenu (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % --- Executes on button press in animateBox. function animateBox_Callback(hObject, eventdata, handles) % hObject handle to animateBox (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hint: get(hObject,'Value') returns toggle state of animateBox val = get(hObject,'Value'); if(~val) set(handles.timeEndArea,'Enable','off') set(handles.timeSkipArea,'Enable','off') set(handles.timeEndArea,'Background',[.8 .8 .8]) set(handles.timeSkipArea,'Background',[.8 .8 .8]) else set(handles.timeEndArea,'Enable','on') set(handles.timeSkipArea,'Enable','on') set(handles.timeEndArea,'Background',[1 1 1]) set(handles.timeSkipArea,'Background',[1 1 1]) end function timeStartArea_Callback(hObject, eventdata, handles) % hObject handle to timeStartArea (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: get(hObject,'String') returns contents of timeStartArea as text % str2double(get(hObject,'String')) returns contents of timeStartArea as a double % --- Executes during object creation, after setting all properties. function timeStartArea_CreateFcn(hObject, eventdata, handles) % hObject handle to timeStartArea (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end function timeSkipArea_Callback(hObject, eventdata, handles) % hObject handle to timeSkipArea (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: get(hObject,'String') returns contents of timeSkipArea as text % str2double(get(hObject,'String')) returns contents of timeSkipArea as a double % --- Executes during object creation, after setting all properties. function timeSkipArea_CreateFcn(hObject, eventdata, handles) % hObject handle to timeSkipArea (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end function timeEndArea_Callback(hObject, eventdata, handles) % hObject handle to timeEndArea (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: get(hObject,'String') returns contents of timeEndArea as text % str2double(get(hObject,'String')) returns contents of timeEndArea as a double % --- Executes during object creation, after setting all properties. function timeEndArea_CreateFcn(hObject, eventdata, handles) % hObject handle to timeEndArea (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end % --- Executes on selection change in colormapMenu. function colormapMenu_Callback(hObject, eventdata, handles) % hObject handle to colormapMenu (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: contents = get(hObject,'String') returns colormapMenu contents as cell array % contents{get(hObject,'Value')} returns selected item from colormapMenu try val = get(hObject,'Value'); cm = get(hObject,'String'); figure(handles.dplot) eval(['colormap ' char(cm(val))]); catch end % --- Executes during object creation, after setting all properties. function colormapMenu_CreateFcn(hObject, eventdata, handles) % hObject handle to colormapMenu (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: popupmenu controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end function cMinBox_Callback(hObject, eventdata, handles) % hObject handle to cMinBox (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: get(hObject,'String') returns contents of cMinBox as text % str2double(get(hObject,'String')) returns contents of cMinBox as a double % --- Executes during object creation, after setting all properties. function cMinBox_CreateFcn(hObject, eventdata, handles) % hObject handle to cMinBox (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end function cMaxBox_Callback(hObject, eventdata, handles) % hObject handle to cMaxBox (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: get(hObject,'String') returns contents of cMaxBox as text % str2double(get(hObject,'String')) returns contents of cMaxBox as a double % --- Executes during object creation, after setting all properties. function cMaxBox_CreateFcn(hObject, eventdata, handles) % hObject handle to cMaxBox (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end function externalFunctionBox_Callback(hObject, eventdata, handles) % hObject handle to externalFunctionBox (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: get(hObject,'String') returns contents of externalFunctionBox as text % str2double(get(hObject,'String')) returns contents of externalFunctionBox as a double % --- Executes during object creation, after setting all properties. function externalFunctionBox_CreateFcn(hObject, eventdata, handles) % hObject handle to externalFunctionBox (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end % --- Executes on button press in hiResCoastBox. function hiResCoastBox_Callback(hObject, eventdata, handles) % hObject handle to hiResCoastBox (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hint: get(hObject,'Value') returns toggle state of hiResCoastBox function landColourBox_Callback(hObject, eventdata, handles) % hObject handle to landColourBox (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: get(hObject,'String') returns contents of landColourBox as text % str2double(get(hObject,'String')) returns contents of landColourBox as a double % --- Executes during object creation, after setting all properties. function landColourBox_CreateFcn(hObject, eventdata, handles) % hObject handle to landColourBox (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end % --- Executes on button press in patchCoastBox. function patchCoastBox_Callback(hObject, eventdata, handles) % hObject handle to patchCoastBox (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hint: get(hObject,'Value') returns toggle state of patchCoastBox % --- Executes on button press in RVOCheckbox. function RVOCheckbox_Callback(hObject, eventdata, handles) % hObject handle to RVOCheckbox (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hint: get(hObject,'Value') returns toggle state of RVOCheckbox % --- Executes on selection change in messageList. function messageList_Callback(hObject, eventdata, handles) % hObject handle to messageList (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: contents = cellstr(get(hObject,'String')) returns messageList contents as cell array % contents{get(hObject,'Value')} returns selected item from messageList % --- Executes during object creation, after setting all properties. function messageList_CreateFcn(hObject, eventdata, handles) % hObject handle to messageList (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: listbox controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end function vecScaleTextBox_Callback(hObject, eventdata, handles) % hObject handle to vecScaleTextBox (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: get(hObject,'String') returns contents of vecScaleTextBox as text % str2double(get(hObject,'String')) returns contents of vecScaleTextBox as a double % --- Executes during object creation, after setting all properties. function vecScaleTextBox_CreateFcn(hObject, eventdata, handles) % hObject handle to vecScaleTextBox (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end function vecSkipXBox_Callback(hObject, eventdata, handles) % hObject handle to vecSkipXBox (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: get(hObject,'String') returns contents of vecSkipXBox as text % str2double(get(hObject,'String')) returns contents of vecSkipXBox as a double % --- Executes during object creation, after setting all properties. function vecSkipXBox_CreateFcn(hObject, eventdata, handles) % hObject handle to vecSkipXBox (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end function vecSkipYBox_Callback(hObject, eventdata, handles) % hObject handle to vecSkipYBox (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: get(hObject,'String') returns contents of vecSkipYBox as text % str2double(get(hObject,'String')) returns contents of vecSkipYBox as a double % --- Executes during object creation, after setting all properties. function vecSkipYBox_CreateFcn(hObject, eventdata, handles) % hObject handle to vecSkipYBox (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end % --- Executes on button press in vecOverplotBox. function vecOverplotBox_Callback(hObject, eventdata, handles) % hObject handle to vecOverplotBox (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hint: get(hObject,'Value') returns toggle state of vecOverplotBox function vecColourBox_Callback(hObject, eventdata, handles) % hObject handle to vecColourBox (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: get(hObject,'String') returns contents of vecColourBox as text % str2double(get(hObject,'String')) returns contents of vecColourBox as a double % --- Executes during object creation, after setting all properties. function vecColourBox_CreateFcn(hObject, eventdata, handles) % hObject handle to vecColourBox (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end % -------------------------------------------------------------------- function quitMenuOption_Callback(hObject, eventdata, handles) % hObject handle to quitMenuOption (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % -------------------------------------------------------------------- function datasetMenu_Callback(hObject, eventdata, handles) % hObject handle to datasetMenu (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % -------------------------------------------------------------------- function ukmoNaeMenuOption_Callback(hObject, eventdata, handles) % hObject handle to ukmoNaeMenuOption (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) isChecked = strcmp(get(handles.ukmoNaeMenuOption,'Checked'),'on'); if(isChecked) set(handles.ukmoNaeMenuOption,'Checked','off'); else set(handles.ukmoNaeMenuOption,'Checked','on'); end %--------------------------------------------------------------------- function [lon lat field lon_index lat_index] = regridNAE(lon,lat,fieldin,nvars,lon_min,lon_max,lat_min,lat_max); updateStatus(' -> Interpolating UKMO for vector desampling...',0); lats = 14:.1:80; lons = -90:.1:62; fieldin = double(fieldin); for(i=1:nvars) field2(:,:,i) = griddata(double(lon),double(lat),fieldin(:,:,i),lons',lats)'; end field = field2; lon = lons; lat = lats; lon_index = find(lon >= lon_min & lon <= lon_max); lat_index = find(lat >= lat_min & lat <= lat_max); [lon lat] = meshgrid(lon,lat); % if(~min(size(lon) == size(field(:,:,1)))) lon = lon'; lat = lat'; % end % --- Executes on selection change in verticalLevelMenu. function verticalLevelMenu_Callback(hObject, eventdata, handles) % hObject handle to verticalLevelMenu (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: contents = cellstr(get(hObject,'String')) returns verticalLevelMenu contents as cell array % contents{get(hObject,'Value')} returns selected item from verticalLevelMenu % --- Executes during object creation, after setting all properties. function verticalLevelMenu_CreateFcn(hObject, eventdata, handles) % hObject handle to verticalLevelMenu (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: popupmenu controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end %================================================== function checkVersion(thisVersion) versionURL = 'http://www.dajs.org.uk/code/ncdfView/version'; changeURL = 'http://www.dajs.org.uk/code/ncdfView/CHANGELOG'; try currentVersion = str2double(urlread(versionURL)); if(thisVersion==currentVersion) updateStatus(' -> ncdfView is up to date',0); else updateStatus(' -> A new version of ncdfView is available...',0); updateStatus([' This version: ' num2str(thisVersion)],0); updateStatus([' Current version: ' num2str(currentVersion)],0); updateStatus(' -> See www.dajs.org.uk/tools.php',0); disp(urlread(changeURL)); updateStatus(' -> Changelog written to console.',0) end catch updateStatus('Warning: couldn''t version-check (no network access?)'); end % --- Executes on button press in resetButton. function resetButton_Callback(hObject, eventdata, handles) % hObject handle to resetButton (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) set(handles.variablesList,'Value',1); set(handles.variablesList,'String',{''}); set(handles.fileList,'Value',1); set(handles.fileList,'String',{''}); set(handles.zonalMenu,'Value',1); set(handles.zonalMenu,'String',{''}); set(handles.meridionalMenu,'Value',1); set(handles.meridionalMenu,'String',{''}); set(handles.verticalMenu,'Value',1); set(handles.verticalMenu,'String',{''}); set(handles.timeMenu,'Value',1); set(handles.timeMenu,'String',{''}); handles.files = []; handles.numFiles = 0; handles.paths = []; %------------------------------------------ handles.varNames = []; handles.files = []; handles.dimNames = []; %========================================================================== function output = readnc(filename, varname, lev) [ncid, status] = mexnc('open', filename); [varid, status] = mexnc('inq_varid', ncid, varname); [output, status] = mexnc('get_var_double', ncid, varid); mexnc('close',ncid);