dump = dict(z=z, title=title, dims=dims, xlabel=xlabel, ylabel=ylabel, zlabel=zlabel) # print dump return json.dumps(dump, sort_keys=True, indent=2) # return json.dumps(dump) # Load module def load_action(files=None, intent=None): print "loading", files result = [_load_data(f) for f in files] # not bundles return dict(output=result) def _load_data(name): (dirName, fileName) = os.path.split(name) return LoadICPData(fileName, path=dirName, auto_PolState=True) load = load_module(id='ospec.load', datatype=OSPEC_DATA, version='1.0', action=load_action) # Save module def save_action(input=None, ext=None): for f in input: _save_one(f, ext) # not bundles return {} def _save_one(input, ext): default_filename = "default.cg1" # modules like autogrid return MetaArrays that don't have filenames outname = initname = input.extrainfo["path"] + "/" + input.extrainfo.get("filename", default_filename) if ext is not None: outname = ".".join([os.path.splitext(outname)[0], ext]) print "saving", initname, 'as', outname input.write(outname) save = save_module(id='ospec.save', datatype=OSPEC_DATA,
else: result.append(subresult) return dict(output=result) ''' ################################################################################ # NOTE: 02/03/2012 bbm # this is what was in "load_action" before # it would clearly not work - the directory was hardcoded, # and relied on a directory structure # that will not exist on a typical machine (i.e. /home/brendan...) # # the replacement above is an adaptation of the loader code in # dataflow/dataflow/offspecular/instruments.py ################################################################################ load = load_module(id='tas.load', datatype=TAS_DATA, version='1.0') ''' def _load_chalk_data(aof_filename, orient1, orient2, acf_filename=None): #(dirName, fileName) = os.path.split(name) #friendlyName = get_friendly_name(fileName) return data_abstraction.chalk_filereader(aof_filename, orient1, orient2, acf_filename=acf_filename) def load_chalk_action(chalk_files=[], h1=None, k1=None, l1=None, h2=None, k2=None, l2=None, **kwargs): print "loading chalk river" result = [] orient1 = [] orient2 = [] aof_filename = None
else: result.append(subresult) return dict(output=result) ''' ################################################################################ # NOTE: 02/03/2012 bbm # this is what was in "load_action" before # it would clearly not work - the directory was hardcoded, # and relied on a directory structure # that will not exist on a typical machine (i.e. /home/brendan...) # # the replacement above is an adaptation of the loader code in # dataflow/dataflow/offspecular/instruments.py ################################################################################ load = load_module(id='tas.load', datatype=TAS_DATA, version='1.0') ''' def _load_chalk_data(aof_filename, orient1, orient2, acf_filename=None): #(dirName, fileName) = os.path.split(name) #friendlyName = get_friendly_name(fileName) return data_abstraction.chalk_filereader(aof_filename, orient1, orient2, acf_filename=acf_filename) def load_chalk_action(chalk_files=[], h1=None, k1=None, l1=None, h2=None, k2=None, l2=None, **kwargs): print "loading chalk river" result = [] orient1 = [] orient2 = [] aof_filename = None aof_file = None