Skip to content

Commit

Permalink
refs #6667 Checkpoint.
Browse files Browse the repository at this point in the history
Trying to reduce monovanadium and it does not work.
  • Loading branch information
abuts committed Jun 25, 2013
1 parent 4c28e76 commit 9641649
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 31 deletions.
43 changes: 33 additions & 10 deletions Code/Mantid/scripts/Inelastic/DirectEnergyConversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,9 +256,9 @@ def mono_sample(self, mono_run, ei_guess, white_run=None, map_file=None,
if result_name is None:
result_name = common.create_resultname(mono_run, prefix=self.instr_name)

self.workspaces_list['sample_ws']=self._do_mono(sample_data, sample_data, result_name, ei_guess,
self.workspace_list['sample_ws']=self._do_mono(sample_data, sample_data, result_name, ei_guess,
white_run, map_file, spectra_masks, Tzero)
return self.workspaces_list['sample_ws']
return self.workspace_list['sample_ws']


# -------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -695,7 +695,7 @@ def save_results(self, workspace, save_path, formats = None):
# if ext is none, no need to write anything
if len(ext) == 1 and ext[0] == None :
return
self.psi = 1000000; # for test
#self.psi = 1000000; # for test
save_path = os.path.splitext(save_path)[0]
for ext in formats:
if ext in self.__save_formats :
Expand Down Expand Up @@ -750,22 +750,41 @@ def save_format(self):

@save_format.setter
def save_format(self, value):
if value not in self.__save_formats :
self.log("Trying to set unknown format: \""+str(value)+"\" No saving will occur")
value = None
if value is None:
self._save_format = None

if isinstance(value,str):
if value not in self.__save_formats :
self.log("Trying to set unknown format: \""+str(value)+"\" No saving will occur")
value = None
elif isinstance(value,list):
if len(value) > 0 :
value = value[0]
else:
value = None
self.save_format = value

self._save_format = value

@property
def energy_bins(self):
return self._energy_bins;

@energy_bins.setter
def energy_bins(self,value):
if value != None:
if value != None:
if isinstance(value,str):
list = str.split(value,',');
value = [float(list[0]),float(list[1]),float(list[2])]
if len(value) != 3:
raise KeyError("Energy_bin value has to be either list of 3 numbers or string, representing these three number separated by commas")
nBlocks = len(list);
for i in xrange(0,nBlocks,3):
value = [float(list[i]),float(list[i+1]),float(list[i+2])]
else:
nBlocks = len(value);
if nBlocks%3 != 0:
raise KeyError("Energy_bin value has to be either list of n-blocks of 3 number each or string representation of this list with numbers separated by commas")




self._energy_bins= value;
@property
Expand Down Expand Up @@ -1005,6 +1024,8 @@ def set_input_parameters(self,**kwargs):
# whole composite key is modified by input parameters
if par_name in self.composite_keys_set :
val = getattr(self,par_name) # get default value
if isinstance(value,str) and value.lower()[0:7] == 'default' : # Property changed but default value requesed explicitly
value = val
if type(val) != type(value):
raise KeyError("Attempt to change range property: "+par_name+" of type : "+str(type(val))+ " with wrong type value: "+str(type(value)))
if len(val) != len(value) :
Expand All @@ -1016,6 +1037,8 @@ def set_input_parameters(self,**kwargs):
continue

# simple case of setting simple value
if isinstance(value,str) and value.lower()[0:7] == 'default' : # Property changed but default value requesed explicitly
value = getattr(self,par_name)
setattr(self,par_name,value)
properties_changed.append(par_name)

Expand Down
27 changes: 6 additions & 21 deletions Code/Mantid/scripts/Inelastic/dgreduce.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def help(keyword=None) :
Reducer.help(keyword)


def arb_units(wb_run,sample_run,ei_guess,rebin,map_file=None,monovan_run=None,**kwargs):
def arb_units(wb_run,sample_run,ei_guess,rebin,map_file='default',monovan_run=None,**kwargs):
"""
arb_units(wb_run,sample_run,ei_guess,rebin,mapfile,**kwargs)
Expand Down Expand Up @@ -195,9 +195,8 @@ def arb_units(wb_run,sample_run,ei_guess,rebin,map_file=None,monovan_run=None,**


# map file given in parameters overrides default map file
if map_file != None :
if map_file != 'default' :
Reducer.map_file = map_file

# defaults can be None too, but can be a file
if Reducer.map_file == None:
Reducer.log('one2one map selected')
Expand Down Expand Up @@ -244,26 +243,12 @@ def arb_units(wb_run,sample_run,ei_guess,rebin,map_file=None,monovan_run=None,**
if monovan_run != None :
if Reducer.mono_correction_factor == None :
if Reducer.use_sam_msk_on_monovan == True:
Reducer.log(' Applying sample run mask to mono van NOT IMPLEMENTED')
#TODO:
#monovan_ws=common.load_run(monovan_run)
#MaskDetectors(Workspace=monovan_ws, MaskedWorkspace=masking)
#if wb_for_monovanadium != wb_run:
# wb_for_monovan_ws=common.load_run(wb_for_monovanadium)
# MaskDetectors(Workspace=wb_for_monovan_ws, MaskedWorkspace=masking)
Reducer.log(' Applying sample run mask to mono van')
else:
print '########### Run diagnose for monochromatic vanadium run ##############'
masking2 = Reducer.diagnose(wb_for_monovanadium,sample=monovan_run,
second_white = None,variation=1.1,print_results=True)

if wb_for_monovanadium != wb_run:
pass
# combine monovan_run and sample_run masks
#TODO
#MaskDetectors(Workspace=monovan_run,MaskedWorkspace=masking)
# MaskDetectors(Workspace=sample_run,MaskedWorkspace=masking2)
else: # masks have already been combined through common wb_run
pass
masking += masking2


Expand All @@ -272,7 +257,7 @@ def arb_units(wb_run,sample_run,ei_guess,rebin,map_file=None,monovan_run=None,**

Reducer.spectra_masks=masking
# estimate and report the number of failing detectors
failed_sp_list,nSpectra = get_failed_spectra_list(masking)
failed_sp_list,nSpectra = get_failed_spectra_list_from_masks(masking)
nMaskedSpectra = len(failed_sp_list)
print 'Diag processed workspace with {0:d} spectra and found {1:d} bad spectra'.format(nSpectra,nMaskedSpectra)
#Run the conversion first on the sample
Expand Down Expand Up @@ -303,7 +288,7 @@ def arb_units(wb_run,sample_run,ei_guess,rebin,map_file=None,monovan_run=None,**



def abs_units(wb_for_run,sample_run,monovan_run,wb_for_monovanadium,samp_rmm,samp_mass,ei_guess,rebin,map_file,monovan_mapfile,**kwargs):
def abs_units(wb_for_run,sample_run,monovan_run,wb_for_monovanadium,samp_rmm,samp_mass,ei_guess,rebin,map_file='default',monovan_mapfile='default',**kwargs):
"""
dgreduce.abs_units(wb_run Whitebeam run number or file name or workspace
sample_run Sample run run number or file name or workspace
Expand Down Expand Up @@ -440,7 +425,7 @@ def apply_absolute_normalization(Reducer,deltaE_wkspace_sample,monovan_run,ei_gu
if Reducer.monovan_integr_range is None: # integration in the range relative to incident energy
Reducer.monovan_integr_range = [Reducer.monovan_lo_frac*ei_guess,Reducer.monovan_hi_frac*ei_guess]
Reducer.log('##### Evaluate the integral from the monovan run and calculate the correction factor ######')
Reducer.log(' Using absolute units vanadion integration range : '+str(Reducer.monovan_integr_range))
Reducer.log(' Using absolute units vanadium integration range : '+str(Reducer.monovan_integr_range))
#now on the mono_vanadium run swap the mapping file
map_file = Reducer.map_file;
Reducer.map_file = Reducer.monovan_mapfile;
Expand Down

0 comments on commit 9641649

Please sign in to comment.