Changeset 1197


Ignore:
Timestamp:
Mar 11, 2022 11:53:15 AM (9 months ago)
Author:
ilavsky
Message:

Updates for Tiled

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/User Procedures/Indra 2/IN3_BlueSkyReader.ipf

    r1196 r1197  
    6060        string AllCatalogs=""
    6161        SVAR ListOfCatalogs=root:Packages:Irena:BlueSkySamplePlot:ListOfCatalogs
     62        SVAR CatalogUsed=root:Packages:Irena:BlueSkySamplePlot:CatalogUsed
     63       
    6264        ListOfCatalogs=""
    6365        URLRequest/Z url=TempAddress
     
    8284        //overwrite, fails on old catalog:
    8385        //ListOfCatalogs=stringfromList(0,AllCatalogs)
    84         ListOfCatalogs=stringfromList(0,grepList(AllCatalogs,"9idc_usaxs"))
    85 
    86 //      //check these are BlueSKy Catalogs
    87 //      For(i=0;i<NumCatalogs;i+=1)
    88 //              TempAddress =  ServerAddress+"/node/search/?filter[lookup][condition][key]="+StringFromList(i, AllCatalogs)+"&sort="
    89 //              print TempAddress
    90 //      URLRequest/Z url=TempAddress
    91 //      if(V_Flag!=0)
    92 //              abort "Server not available"
    93 //      endif
    94 //      JSONXOP_Parse/Z(S_serverResponse)
    95 //      if(V_Flag!=0)
    96 //              abort "Cannot parse server response"
    97 //      endif
    98 //      variable jsonId = V_Value
    99 //              TempJSONAdd =  "/data/0/attributes/specs/0"     
    100 //              tempStr = JSON_GetString(jsonID, TempJSONAdd)
    101 //              if(stringMatch(tempStr,"CatalogOfBlueskyRuns"))
    102 //                      ListOfCatalogs += tempStr+";"
    103 //              endif
    104 //              JSONXOP_Release jsonId
    105 //      endfor
    106 //     
     86        ListOfCatalogs=AllCatalogs
     87        CatalogUsed = stringfromList(0,grepList(AllCatalogs,"9idc_usaxs"))
     88        //update panel, if exists
     89        DoWIndow IR3BS_BlueSkyPlotPanel
     90        if(V_flag)
     91                SVAR ListOfCatalogs=root:Packages:Irena:BlueSkySamplePlot:ListOfCatalogs
     92                SVAR CatalogUsed=root:Packages:Irena:BlueSkySamplePlot:CatalogUsed
     93                SVAR ScanTypeToUse = root:Packages:Irena:BlueSkySamplePlot:ScanTypeToUse
     94                PopupMenu CatalogUsed,value=#"root:Packages:Irena:BlueSkySamplePlot:ListOfCatalogs",mode=1, popvalue=CatalogUsed
     95                IR3BS_ReadJSONScanData()
     96                PopupMenu ScanTypeToUse,value=#"root:Packages:Irena:BlueSkySamplePlot:ListOfScanTypes",mode=1, popvalue=ScanTypeToUse
     97
     98        endif
    10799        //string        ServerType =JSON_GetString(jsonID, tempAddress)
    108100
     
    134126        // converting date - offset change - correction to UTC
    135127
    136        
    137         //let's list those which are plan "tune_a2rp"
    138 //      variable numDataSets, i, j
    139 //      string tempPlanName, tempAddress
    140 //      numDataSets = JSON_GetArraySize(jsonID, "/data")
    141 //      KillWaves/Z IDwave, PlanNameWave, TimeWave
    142 //      make/O/N=(numDataSets)/T IDwave, PlanNameWave
    143 //      make/O/N=(numDataSets) TimeWave
    144 //      j=0
    145 //      For(i=0;i<numDataSets;i+=1)
    146 //              tempAddress = "/data/"+num2str(i)+"/attributes/metadata/start/plan_name"
    147 //              tempPlanName = JSON_GetString(jsonID, tempAddress)
    148 //              if(StringMatch(tempPlanName, "tune_*"))
    149 //                      tempAddress = "/data/"+num2str(i)+"/id"
    150 //                      IDwave[j] = JSON_GetString(jsonID, tempAddress)
    151 //                      PlanNameWave[j]=tempPlanName
    152 //                      tempAddress = "/data/"+num2str(i)+"/attributes/metadata/start/time"
    153 //                      TimeWave[j] = JSON_GetVariable(jsonID, tempAddress) + 2082844800
    154 //                      j+=1
    155 //              endif
    156 //     
    157 //      endfor
    158 //     
    159        
    160 //      JSONXOP_Release jsonId
    161 
    162128end
    163129
     
    180146
    181147        //here define the lists of variables and strings needed, separate names by ;...
    182         ListOfStrings="ListOfCatalogs;"
     148        ListOfStrings="ListOfCatalogs;CatalogUsed;ListOfScanTypes;ScanTypeToUse;"
    183149//      ListOfStrings+="DataStartFolder;DataMatchString;FolderSortString;FolderSortStringAll;"
    184 //      ListOfStrings+="UserMessageString;SavedDataMessage;"
    185 //      ListOfStrings+="SelectedResultsTool;SelectedResultsType;ResultsGenerationToUse;"
    186 //      ListOfStrings+="DataSubTypeUSAXSList;DataSubTypeResultsList;DataSubType;"
    187 //      ListOfStrings+="GraphUserTitle;GraphWindowName;XAxisLegend;YAxislegend;"
    188 //      ListOfStrings+="QvecLookupUSAXS;ErrorLookupUSAXS;dQLookupUSAXS;"
    189 //      ListOfStrings+="ListOfDefinedStyles;SelectedStyle;ListOfDefinedDataPlots;SelectedDataPlot;"
    190150
    191151        ListOfVariables="StartYear;StartMoth;StartDay;NumOfHours;"
    192152//      ListOfVariables="UseIndra2Data;UseQRSdata;UseResults;"
    193 //      ListOfVariables+="InvertGrepSearch;"
    194 //      ListOfVariables+="LogXAxis;LogYAxis;MajorGridXaxis;MajorGridYaxis;MinorGridXaxis;MinorGridYaxis;"
    195 //      ListOfVariables+="Colorize;UseSymbols;UseLines;SymbolSize;LineThickness;"
    196 //      ListOfVariables+="XOffset;YOffset;DisplayErrorBars;ApplyFormatingEveryTime;"
    197 //      ListOfVariables+="AddLegend;UseOnlyFoldersInLegend;LegendSize;"
    198        
     153
    199154        //and here we create them
    200155        for(i=0;i<itemsInList(ListOfVariables);i+=1)   
     
    206161        endfor 
    207162
    208         ListOfStrings="ListOfCatalogs;"
     163        ListOfStrings="ListOfCatalogs;CatalogUsed;"
    209164        for(i=0;i<itemsInList(ListOfStrings);i+=1)     
    210165                SVAR teststr=$(StringFromList(i,ListOfStrings))
     
    243198               
    244199
    245         Make/O/T/N=(0,2) ListOfAvailableData
     200        Make/O/T/N=(0,3) ListOfAvailableData, PrunedListOfAvailableData
    246201        Make/O/N=(0) SelectionOfAvailableData
    247202        SetDataFolder oldDf
     
    266221
    267222
     223        SVAR ListOfCatalogs=root:Packages:Irena:BlueSkySamplePlot:ListOfCatalogs
     224        SVAR CatalogUsed=root:Packages:Irena:BlueSkySamplePlot:CatalogUsed
     225        PopupMenu CatalogUsed,pos={20,40},size={310,20},proc=IR3BS_PopMenuProc, title="Select Catalog",help={"Select one of available catalogs"}
     226        PopupMenu CatalogUsed,value=#"root:Packages:Irena:BlueSkySamplePlot:ListOfCatalogs",mode=1, popvalue=CatalogUsed
     227
    268228        //ListOfVariables="StartMoth;StartDay;NumOfHours;"
    269         SetVariable StartYear,pos={20,40},size={100,20}, proc=IN3BS_ListBoxMenuProc,title="\Zr120Year:", valueColor=(0,0,0)
    270         Setvariable StartYear,fStyle=0, variable=root:Packages:Irena:BlueSkySamplePlot:StartYear, disable=0, frame=1, help={"This is Igro internal name for graph currently selected for controls"}
    271         SetVariable StartMoth,pos={140,40},size={100,20}, proc=IR3BS_SetVarProc,title="\Zr120Month:", valueColor=(0,0,0)
    272         Setvariable StartMoth,fStyle=0, variable=root:Packages:Irena:BlueSkySamplePlot:StartMoth, disable=0, frame=1, help={"This is Igro internal name for graph currently selected for controls"}
    273         SetVariable StartDay,pos={260,40},size={100,20}, proc=IR3BS_SetVarProc,title="\Zr120Day:", valueColor=(0,0,0)
    274         Setvariable StartDay,fStyle=0, variable=root:Packages:Irena:BlueSkySamplePlot:StartDay, disable=0, frame=1, help={"This is Igro internal name for graph currently selected for controls"}
    275         SetVariable NumOfHours,pos={80,70},size={100,20}, proc=IR3BS_SetVarProc,title="\Zr120Hours:", valueColor=(0,0,0)
    276         Setvariable NumOfHours,fStyle=0, variable=root:Packages:Irena:BlueSkySamplePlot:NumOfHours, disable=0, frame=1, help={"This is Igro internal name for graph currently selected for controls"}
    277 
    278         Button Update,pos={270,70},size={120,20}, proc=IR3BS_ButtonProc,title="Update", help={"Plot selected data in new graph"}
     229        SetVariable StartYear,pos={20,70},size={100,20}, proc=IN3BS_ListBoxMenuProc,title="\Zr120Year:", valueColor=(0,0,0)
     230        Setvariable StartYear,fStyle=0, variable=root:Packages:Irena:BlueSkySamplePlot:StartYear, disable=0, frame=1, help={"This is Igor internal name for graph currently selected for controls"}
     231        SetVariable StartMoth,pos={140,70},size={100,20}, proc=IR3BS_SetVarProc,title="\Zr120Month:", valueColor=(0,0,0)
     232        Setvariable StartMoth,fStyle=0, variable=root:Packages:Irena:BlueSkySamplePlot:StartMoth, disable=0, frame=1, help={"This is Igor internal name for graph currently selected for controls"}
     233        SetVariable StartDay,pos={260,70},size={100,20}, proc=IR3BS_SetVarProc,title="\Zr120Day:", valueColor=(0,0,0)
     234        Setvariable StartDay,fStyle=0, variable=root:Packages:Irena:BlueSkySamplePlot:StartDay, disable=0, frame=1, help={"This is Igor internal name for graph currently selected for controls"}
     235        SetVariable NumOfHours,pos={370,70},size={100,20}, proc=IR3BS_SetVarProc,title="\Zr120Hours:", valueColor=(0,0,0)
     236        Setvariable NumOfHours,fStyle=0, variable=root:Packages:Irena:BlueSkySamplePlot:NumOfHours, disable=0, frame=1, help={"This is Igor internal name for graph currently selected for controls"}
     237
     238        SVAR ListOfScanTypes=root:Packages:Irena:BlueSkySamplePlot:ListOfScanTypes
     239        SVAR ScanTypeToUse=root:Packages:Irena:BlueSkySamplePlot:ScanTypeToUse
     240        PopupMenu ScanTypeToUse,pos={20,100},size={310,20},proc=IR3BS_PopMenuProc, title="Select Scan type",help={"Select one of available scan types"}
     241        PopupMenu ScanTypeToUse,value=#"root:Packages:Irena:BlueSkySamplePlot:ListOfScanTypes",mode=1, popvalue=ScanTypeToUse
     242
     243        Button Update,pos={300,100},size={150,20}, proc=IR3BS_ButtonProc,title="Update", help={"Plot selected data in new graph"}
    279244
    280245        ListBox BlueSkyList,pos={8,185},size={573,395} //, special={0,0,1 }             //this will scale the width of column, users may need to slide right using slider at the bottom.
    281         ListBox BlueSkyList,listWave=root:Packages:Irena:BlueSkySamplePlot:ListOfAvailableData
     246        ListBox BlueSkyList,listWave=root:Packages:Irena:BlueSkySamplePlot:PrunedListOfAvailableData
    282247        ListBox BlueSkyList,selWave=root:Packages:Irena:BlueSkySamplePlot:SelectionOfAvailableData
    283248        ListBox BlueSkyList,proc=IN3BS_ListBoxMenuProc, selRow= 0, editStyle= 0
     249        ListBox BlueSkyList widths={20,30,0}
    284250        ListBox BlueSkyList userColumnResize=1,help={"Fill here list of samples, their positions, thickness etc. "}
    285251        //ListBox BlueSkyList titleWave=root:Packages:SamplePlateSetup:LBTtitleWv, frame= 2
     
    287253        ListBox BlueSkyList  mode=1             // mode=1 for single row selection, 4 multiple disjoint rows (shift only), mode=9 for shift conigous+ctrl disjoint. 
    288254
    289 
    290         //      PopupMenu SelectGraphWindows,pos={280,90},size={310,20},proc=IR3L_PopMenuProc, title="Select Graph",help={"Select one of controllable graphs"}
    291         //      PopupMenu SelectGraphWindows,value=IR3L_GraphListPopupString(),mode=1, popvalue=GraphWindowName
    292         //     
    293         //      SetVariable GraphWindowName,pos={280,115},size={310,20}, proc=IR3L_SetVarProc,title="\Zr120Graph Window name: ", noedit=1, valueColor=(65535,0,0)
    294         //      Setvariable GraphWindowName,fStyle=2, variable=root:Packages:Irena:MultiSamplePlot:GraphWindowName, disable=0, frame=0, help={"This is Igro internal name for graph currently selected for controls"}
    295         //
    296         //      SetVariable GraphUserTitle,pos={280,140},size={310,20}, proc=IR3L_SetVarProc,title="\Zr120Graph title: "
    297         //      Setvariable GraphUserTitle,fStyle=2, variable=root:Packages:Irena:MultiSamplePlot:GraphUserTitle, help={"This is human name for graph currently controlled by the tool. You can change it."}
    298         //
    299255        //      //Plotting controls...
    300256        //      TitleBox FakeLine1 title=" ",fixedSize=1,size={330,3},pos={260,170},frame=0,fColor=(0,0,52224), labelBack=(0,0,52224)
    301         //     
    302         //      Button NewGraphPlotData,pos={270,180},size={120,20}, proc=IR3L_ButtonProc,title="New graph", help={"Plot selected data in new graph"}
    303         //      Button AppendPlotData,pos={410,180},size={180,20}, proc=IR3L_ButtonProc,title="Append to selected graph", help={"Append selected data to graph selected above"}
    304         //      //this is selection of data types the code will plot.
    305         //      SVAR SelectedDataPlot=root:Packages:Irena:MultiSamplePlot:SelectedDataPlot
    306         //      PopupMenu SelectedDataPlot,pos={260,215},size={310,20},proc=IR3L_PopMenuProc, title="\Zr120Data type to plot?  : ",help={"Select data to create if needed to graph"}
    307         //      PopupMenu SelectedDataPlot,value=#"root:Packages:Irena:MultiSamplePlot:ListOfDefinedDataPlots",mode=1, popvalue=SelectedDataPlot, bodyWidth=150
    308         //      PopupMenu SelectedDataPlot fstyle=5,fColor=(0,0,65535)
    309         //      TitleBox SelectedDataPlotInstructions title="\Zr100",size={245,15},pos={260,240},frame=0,fColor=(0,0,65535),labelBack=0
    310257
    311258end
     
    368315        variable selRow
    369316       
    370         Wave/T IDwave = root:Packages:Irena:BlueSkySamplePlot:IDwave
    371         Wave/T ListOfAvailableData =  root:Packages:Irena:BlueSkySamplePlot:ListOfAvailableData
    372         SVAR ListOfCatalogs=root:Packages:Irena:BlueSkySamplePlot:ListOfCatalogs
     317        //Wave/T IDwave = root:Packages:Irena:BlueSkySamplePlot:IDwave
     318        Wave/T PrunedListOfAvailableData =  root:Packages:Irena:BlueSkySamplePlot:PrunedListOfAvailableData
     319        SVAR CatalogUsed=root:Packages:Irena:BlueSkySamplePlot:CatalogUsed
    373320        //http://usaxscontrol:8000/node/full/9idc_usaxs/16248ab5-1359-4242-8ec9-6fd66f8b5976/primary/data?format=json
    374321       
    375         string TempAddress = ServerAddress+"/api/node/full/"+StringFromList(0, ListOfCatalogs)+"/"
    376         TempAddress +=IDwave[selRow]+"/primary/data?format=json"
     322        string TempAddress = ServerAddress+"/api/node/full/"+CatalogUsed+"/"
     323        TempAddress +=PrunedListOfAvailableData[selRow][2]+"/primary/data?format=json"
    377324        //print TempAddress
    378325        URLRequest/Z url=TempAddress
     
    389336        //print S_Value         //-- prints the file in history and works.
    390337        wave/T Keys = JSON_GetKeys(jsonID, "")
     338        if(numpnts(Keys)<2)
     339                JSONXOP_Release jsonId
     340                abort "Cannot parse response, server not returning meanigful data yet"
     341        endif
    391342        string DetKey = Keys[0]
    392343        string XdataKey = Keys[1]
     
    397348        //store data here and do something with them.
    398349
     350
     351
    399352        Duplicate/O DetFree,Detector
    400353        Duplicate/O XdatFree,Xdata
     
    402355       
    403356        //display, for now this is simplistic way
    404         Display/K=1  Detector vs Xdata as ListOfAvailableData[selRow][1]+"     "+ListOfAvailableData[selRow][0]
     357        Display/K=1  Detector vs Xdata as PrunedListOfAvailableData[selRow][1]+"     "+PrunedListOfAvailableData[selRow][0]
    405358        Label bottom XdataKey
    406359        Label left DetKey
     
    481434        NVAR StartYear=root:Packages:Irena:BlueSkySamplePlot:StartYear
    482435        SVAR ListOfCatalogs=root:Packages:Irena:BlueSkySamplePlot:ListOfCatalogs
     436        SVAR CatalogUsed=root:Packages:Irena:BlueSkySamplePlot:CatalogUsed
     437       
     438
    483439        //SERVER/node/search/CATALOG?page[offset]=0&filter[time_range][condition][since]=FROM_START_TIME&filter[time_range][condition][until]=BEFORE_END_TIME&sort=time
    484440        variable startTimeSec= date2secs((StartYear), (StartMonth), (StartDay)) - 2082844800    //convert to Python time
     
    489445        sprintf EndTimeStr, "%.15g" ,endTimeSec
    490446       
    491         TempAddress +=StringFromList(0, ListOfCatalogs)+"?page[offset]=00&page[limit]=1000&filter[time_range][condition][since]="+StartTimeStr+"&filter[time_range][condition][until]="+EndTimeStr+"&sort=time"
     447        TempAddress +=CatalogUsed+"?page[offset]=00&page[limit]=1000&filter[time_range][condition][since]="+StartTimeStr+"&filter[time_range][condition][until]="+EndTimeStr+"&sort=time"
    492448        //this fails on IP8:
    493449        //TempAddress +=StringFromList(0, ListOfCatalogs)+"?page[offset]=00&page[limit]=1000&filter[time_range][condition][since]="+num2str(startTimeSec, "%.15g")+"&filter[time_range][condition][until]="+num2str(endTimeSec, "%.15g")+"&sort=time"
     
    552508        endfor
    553509        JSONXOP_Release jsonId
    554 
     510       
    555511        //populate listbox
    556512        wave/T ListOfAvailableData = root:Packages:Irena:BlueSkySamplePlot:ListOfAvailableData
    557513        Wave SelectionOfAvailableData = root:Packages:Irena:BlueSkySamplePlot:SelectionOfAvailableData
    558         redimension/N=(j,2) ListOfAvailableData
     514        redimension/N=(j,3) ListOfAvailableData
    559515        redimension/N=(j) SelectionOfAvailableData
    560516        SelectionOfAvailableData = 0
     
    562518                ListOfAvailableData[][0] = PlanNameWave[p]
    563519                ListOfAvailableData[][1] = Secs2Date(TimeWave[p],-2)+"   "+Secs2Time(TimeWave[p],3)
    564         endif
    565        
    566        
     520                ListOfAvailableData[][2] = IDwave[p]
     521        endif
     522       
     523        //create list of scans available on server
     524        SVAR ListOfScanTypes=root:Packages:Irena:BlueSkySamplePlot:ListOfScanTypes
     525        SVAR ScanTypeToUse=root:Packages:Irena:BlueSkySamplePlot:ScanTypeToUse
     526        ListOfScanTypes = ""
     527        ScanTypeToUse = ""
     528        For(i=0;i<DimSize(ListOfAvailableData,0);i+=1)
     529                if(!StringMatch(ListOfScanTypes,"*"+ListOfAvailableData[i][0]+";*"))
     530                        ListOfScanTypes +=ListOfAvailableData[i][0]+";"
     531                endif
     532        endfor
     533        if(strlen(ScanTypeToUse)<1 && DimSize(ListOfAvailableData,0)>0)
     534                ScanTypeToUse = StringFromList(0, ListOfScanTypes)
     535        endif
     536       
     537        IR3BS_UdateListBoxScans()
     538       
     539end
     540
     541
     542Function IR3BS_UdateListBoxScans()
     543
     544        //populate listbox
     545        wave/T ListOfAvailableData = root:Packages:Irena:BlueSkySamplePlot:ListOfAvailableData
     546        Wave/T PrunedListOfAvailableData  =root:Packages:Irena:BlueSkySamplePlot:PrunedListOfAvailableData
     547        redimension/N=(0,3) PrunedListOfAvailableData
     548        Wave SelectionOfAvailableData = root:Packages:Irena:BlueSkySamplePlot:SelectionOfAvailableData
     549        //create list of scans available on server
     550        SVAR ListOfScanTypes=root:Packages:Irena:BlueSkySamplePlot:ListOfScanTypes
     551        SVAR ScanTypeToUse=root:Packages:Irena:BlueSkySamplePlot:ScanTypeToUse
     552
     553        Grep /A /E=(ScanTypeToUse)/GCOL=0  ListOfAvailableData as PrunedListOfAvailableData
     554        redimension/N=(DimSize(PrunedListOfAvailableData,0)) SelectionOfAvailableData
     555        SelectionOfAvailableData = 0
     556
    567557end
    568558
Note: See TracChangeset for help on using the changeset viewer.