Changeset 867 for trunk/src/series.m


Ignore:
Timestamp:
Feb 12, 2015, 9:31:47 PM (9 years ago)
Author:
sommeria
Message:

python option added in series and bug corrections

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/series.m

    r863 r867  
    135135[path_series,name,ext]=fileparts(which('series'));% path to the GUI series
    136136path_series_fct=fullfile(path_series,'series');%path of the functions in subdirectroy 'series'
    137 ActionExtList={'.m';'.sh'};% default choice of extensions (Matlab fct .m or compiled version .sh
     137ActionExtList={'.m';'.sh';'.py (in dev.)'};% default choice of extensions (Matlab fct .m or compiled version .sh
    138138ActionPathList=cell(NbBuiltinAction,1);%initiate the cell matrix of Action fct paths
    139139ActionPathList(:)={path_series_fct}; %set the default path to series fcts to all list members
     
    620620    if ~exist(RootPath,'dir')
    621621        i1_series=[];
    622         RootPath=fileparts(RootPath); %will try the upper folder
     622        %RootPath=fileparts(RootPath); %will try the upper folder
     623        RootFile='';
    623624    else %scan the input folder
    624625        [RootPath,SubDir,RootFile,i1_series,i2_series,j1_series,j2_series,tild,FileInfo,MovieObject]=...
     
    626627    end
    627628    % if no file is found, open a browser
    628     if isempty(i1_series)
     629    if isempty(RootFile)&& isempty(i1_series)
    629630        fileinput=uigetfile_uvmat(['wrong input at line ' num2str(iview) ':pick a new input file'],RootPath);
    630631        if isempty(fileinput)
     
    722723if strcmp(iview,'append') % display the input data as a new line in the table
    723724    iview=size(InputTable,1)+1;% the next line in InputTable becomes the current line
    724     InputTable(iview,:)=[{RootPath},{SubDir},{RootFile},{NomType},{FileExt}];
     725%     InputTable(iview,:)=[{RootPath},{SubDir},{RootFile},{NomType},{FileExt}];
    725726elseif strcmp(iview,'one') % refresh the list of  input  file series
    726727    iview=1; %the first line in InputTable becomes the current line
    727728    InputTable={'','','','',''};
    728     InputTable(iview,:)=[{RootPath},{SubDir},{RootFile},{NomType},{FileExt}];
     729%     InputTable(iview,:)=[{RootPath},{SubDir},{RootFile},{NomType},{FileExt}];
    729730    set(handles.TimeTable,'Data',[{''},{[]},{[]},{[]},{[]}])
    730731    set(handles.MinIndex_i,'Data',[])
     
    742743    SeriesData.Time={};
    743744end
     745   SeriesData.i1_series(iview+1:end)=[];
     746    SeriesData.i2_series(iview+1:end)=[];
     747    SeriesData.j1_series(iview+1:end)=[];
     748    SeriesData.j2_series(iview+1:end)=[];
     749    SeriesData.FileType(iview+1:end)=[];
     750    SeriesData.FileInfo(iview+1:end)=[];
     751    SeriesData.Time(iview+1:end)=[];
     752 InputTable(iview,:)=[{RootPath},{SubDir},{RootFile},{NomType},{FileExt}];
    744753if iview >1
    745754    set(handles.InputLine,'String',num2str(iview))
     
    13961405ActionExt='.m';%default
    13971406if isfield(Param.Action,'ActionExt')
    1398     ActionExt=Param.Action.ActionExt;% '.m' or '.sh' (compiled)
     1407    ActionExt=Param.Action.ActionExt;% '.m', '.sh' (compiled)  or '.py' (Python)
    13991408    Param.Action=rmfield(Param.Action,'ActionExt');%remove from the recorded xml file to avoid interference during ImportConfig
    14001409end
     
    16471656set(handles.status,'UserData',StatusData)
    16481657
     1658
     1659if strcmp(ActionExt, '.py (in dev.)')
     1660    fprintf([
     1661        '\n' ...
     1662        '!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n' ...
     1663        'The option .py is used. It is still in development.\n' ...
     1664        'Do not use it unless you really know what you do!\n' ...
     1665        'To try it, first install Pyp and the most recent version of FluidDyn.\n' ...
     1666        '!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n'])
     1667    RunMode = 'python';
     1668    t = struct2xml(Param);
     1669    t = set(t, 1, 'name', 'Series');
     1670    filexml = fullfile_uvmat(DirXml, '', Param.InputTable{1,3}, '.xml', OutputNomType,...
     1671         Param.IndexRange.first_i, Param.IndexRange.last_i, first_j, last_j);
     1672    save(t, filexml);
     1673end
     1674
     1675
    16491676%% direct processing on the current Matlab session
    16501677if strcmp (RunMode,'local')
     
    16821709        end
    16831710    end
    1684 else
     1711elseif ~strcmp(RunMode,'python')
    16851712    %% processing on a different session of the same computer (background) or cluster, create executable files
    16861713    batch_file_list=cell(NbProcess,1);% initiate the list of executable files
     
    18371864        system(oar_command); 
    18381865        msgbox_uvmat('CONFIRMATION',[ActionName ' launched in cluster: press STATUS to see results'])
     1866    case 'python'
     1867        command = [
     1868            'LD_LIBRARY_PATH=$(echo $LD_LIBRARY_PATH | pyp "p.split('':'') | [s for s in p if ''matlab'' not in s] | '':''.join(p)") ' ...
     1869            'python -m fluiddyn.postproc.uvmat ' filexml];
     1870        % fprintf(['command:\n' command '\n\n'])
     1871        system(command, '-echo');
    18391872end
    18401873
     
    18591892if isfield(Param,'Pairs')
    18601893    Param=rmfield(Param,'Pairs'); %info Pairs not needed for output
     1894end
     1895if isfield(Param,'InputLine')
     1896    Param=rmfield(Param,'InputLine');
     1897end
     1898if isfield(Param,'EditObject')
     1899    Param=rmfield(Param,'EditObject');
    18611900end
    18621901Param.IndexRange.TimeSource=Param.IndexRange.TimeTable{end,1};
     
    23282367    SeriesData=get(handles.series,'UserData');
    23292368    % input line for which the field choice is relevant
    2330     iview=find(strcmp('netcdf',SeriesData.FileType)|strcmp('civx',SeriesData.FileType)|strcmp('civdata',SeriesData.FileType));% all nc files, icluding civ
     2369    iview=find(ismember(SeriesData.FileType,{'netcdf','civx','civdata'}));% all nc files, icluding civ
    23312370    hget_field=findobj(allchild(0),'name','get_field');
    23322371    if ~isempty(hget_field)
     
    23372376    % check the existence of the first file in the series
    23382377    first_j=[];last_j=[];MinIndex_j=1;MaxIndex_j=1;%default setting for index j
    2339     if isfield(Param.IndexRange,'first_j');% if index j is used
     2378    if isfield(Param.IndexRange,'first_j');% if index j is used     
    23402379        first_j=Param.IndexRange.first_j;
    23412380        last_j=Param.IndexRange.last_j;
     
    23462385    if isfield(Param.IndexRange,'PairString'); PairString=Param.IndexRange.PairString{iview}; end
    23472386    [i1,i2,j1,j2] = get_file_index(Param.IndexRange.first_i,first_j,PairString);
    2348     FirstFileName=fullfile_uvmat(InputTable{1},InputTable{2},InputTable{3},...
    2349         InputTable{5},InputTable{4},i1,i2,j1,j2);
     2387    LineIndex=iview(1);
     2388    if numel(iview)>1     
     2389        answer=msgbox_uvmat('INPUT_TXT',['select the line of the input table:' num2str(iview)] ,num2str(iview(1)));
     2390        LineIndex=str2num(answer);
     2391%         InputLine=str2num(get(handles.InputLine,'String'));
     2392%         if ismember(InputLine,iview)
     2393%             LineIndex=InputLine;
     2394%         end
     2395    end
     2396    FirstFileName=fullfile_uvmat(InputTable{LineIndex,1},InputTable{LineIndex,2},InputTable{LineIndex,3},...
     2397        InputTable{LineIndex,5},InputTable{LineIndex,4},i1,i2,j1,j2);
    23502398    if exist(FirstFileName,'file')
    23512399        ParamIn.Title='get_field: pick input variables and coordinates for series processing';
     
    23722420                XName='X';
    23732421                YName='y';
    2374                 set(handles.VelType,'visible','on')
    2375                 set(handles.VelType_title,'visible','on')
    23762422        end
    23772423        set(handles.FieldName,'Value',1)
    23782424        set(handles.FieldName,'String',[FieldList; {'get_field...'}]);
    23792425        if ~strcmp(GetFieldData.FieldOption,'civdata...')
    2380             set(handles.FieldName,'Value',1:numel(FieldList))%select all input fields by default
    2381             set(handles.VelType,'visible','off')
    2382             set(handles.VelType_title,'visible','off')
     2426           if ~isempty(regexp(FieldList{1},'^vec'))
     2427                set(handles.FieldName,'Value',1)
     2428           else
     2429                set(handles.FieldName,'Value',1:numel(FieldList))%select all input fields by default
     2430           end
    23832431            XName=GetFieldData.Coordinates.Coord_x;
    23842432            YName=GetFieldData.Coordinates.Coord_y;
     
    23922440                    TimeName=['att:' GetFieldData.Time.TimeName];
    23932441                    % update the time table
    2394                     TimeTable{iview,2}=get_time(Param.IndexRange.MinIndex_i(iview),MinIndex_j,PairString,InputTable,SeriesData.FileInfo{iview},GetFieldData.Time.TimeName);  % Min time     
    2395                     TimeTable{iview,3}=get_time(Param.IndexRange.first_i,first_j,PairString,InputTable,SeriesData.FileInfo{iview},GetFieldData.Time.TimeName);  % first time             
    2396                     TimeTable{iview,4}=get_time(Param.IndexRange.last_i,last_j,PairString,InputTable,SeriesData.FileInfo{iview},GetFieldData.Time.TimeName);  % last time                     
    2397                     TimeTable{iview,5}=get_time(Param.IndexRange.MaxIndex_i(iview),MaxIndex_j,PairString,InputTable,SeriesData.FileInfo{iview},GetFieldData.Time.TimeName);  % Max time
     2442                    TimeTable{LineIndex,2}=get_time(Param.IndexRange.MinIndex_i(LineIndex),MinIndex_j,PairString,InputTable,SeriesData.FileInfo{LineIndex},GetFieldData.Time.TimeName);  % Min time     
     2443                    TimeTable{LineIndex,3}=get_time(Param.IndexRange.first_i,first_j,PairString,InputTable,SeriesData.FileInfo{LineIndex},GetFieldData.Time.TimeName);  % first time             
     2444                    TimeTable{LineIndex,4}=get_time(Param.IndexRange.last_i,last_j,PairString,InputTable,SeriesData.FileInfo{LineIndex},GetFieldData.Time.TimeName);  % last time                     
     2445                    TimeTable{LineIndex,5}=get_time(Param.IndexRange.MaxIndex_i(LineIndex),MaxIndex_j,PairString,InputTable,SeriesData.FileInfo{LineIndex},GetFieldData.Time.TimeName);  % Max time
    23982446                case 'variable'
    23992447                    set(handles.TimeName,'String',['var:' GetFieldData.Time.TimeName])
     
    24092457                    ParamIn.TimeDimName=GetFieldData.Time.TimeName;
    24102458            end
    2411             TimeTable{iview,1}=TimeName;
     2459            TimeTable{LineIndex,1}=TimeName;
    24122460            set(handles.TimeTable,'Data',TimeTable);
    24132461        end
    24142462        set(handles.Coord_x,'String',XName)
    24152463        set(handles.Coord_y,'String',YName)
     2464        set(handles.Coord_x,'Visible','on')
     2465        set(handles.Coord_y,'Visible','on')
    24162466    else
    24172467        msgbox_uvmat('ERROR',[FirstFileName ' does not exist'])
     
    31063156ActionExtList=get(handles.ActionExt,'String');
    31073157ActionExt=ActionExtList{get(handles.ActionExt,'Value')};
    3108 ActionList=get(handles.ActionName,'String');
    3109 ActionName=ActionList{get(handles.ActionName,'Value')};
     3158if strcmp(ActionExt,'.py (in dev.)')
     3159    set(handles.RunMode,'Value',2)
     3160end
     3161% ActionList=get(handles.ActionName,'String');
     3162% ActionName=ActionList{get(handles.ActionName,'Value')};
    31103163
    31113164function num_NbProcess_Callback(hObject, eventdata, handles)
Note: See TracChangeset for help on using the changeset viewer.