- Timestamp:
- Aug 4, 2016 10:11:45 AM (8 years ago)
- Branches:
- master, ESS_GUI, ESS_GUI_Docs, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_iss959, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc, costrafo411, magnetic_scatt, release-4.1.1, release-4.1.2, release-4.2.2, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
- Children:
- cc03f59
- Parents:
- 18e7309
- Location:
- src/sas/sascalc/file_converter
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/sascalc/file_converter/BSLLoader.py
r18e7309 r2760662 1 1 from sas.sascalc.file_converter.core.bsl_loader import CLoader 2 import numpy as np 2 3 3 4 class BSLLoader(CLoader): 4 5 6 # TODO: Change to __init__(self, filename, frame) 7 # and parse n_(pixels/rasters) from header file 8 def __init__(self, filename, frame, n_pixels, n_rasters): 9 CLoader.__init__(self, filename, frame, n_pixels, n_rasters) 10 5 11 # See invertor.py for implementation of pickling and setters/getters 6 7 12 8 13 # def __setattr__(self, name, value): … … 10 15 # # return self.set_param(value) 11 16 # return CBSLLoader.__set_attr__(self, name, value) 12 # 13 # def __getattr__(self, name): 14 # if name == 'val': 15 # return self.get_val() 16 # return CBSLLoader.__getattr__(self, name) 17 18 def __getattr__(self, name): 19 if name == 'filename': 20 return self.get_filename() 21 elif name == 'frame': 22 return self.get_frame() 23 elif name == 'n_pixels': 24 return self.get_n_pixels() 25 elif name == 'n_rasters': 26 return self.get_n_rasters() 27 return CBSLLoader.__getattr__(self, name) 28 29 def create_arr(self): 30 return np.zeros((self.n_rasters, self.n_pixels)) -
src/sas/sascalc/file_converter/c_ext/bsl_loader.c
r18e7309 r2760662 53 53 } 54 54 55 static PyObject *get_filename(CLoader *self, PyObject *args) { 56 return Py_BuildValue("s", self->params.filename); 57 } 58 59 static PyObject *get_frame(CLoader *self, PyObject *args) { 60 return Py_BuildValue("i", self->params.frame); 61 } 62 63 static PyObject *get_n_pixels(CLoader *self, PyObject *args) { 64 return Py_BuildValue("i", self->params.n_pixels); 65 } 66 67 static PyObject *get_n_rasters(CLoader *self, PyObject *args) { 68 return Py_BuildValue("i", self->params.n_rasters); 69 } 70 55 71 static PyObject *load_data(CLoader *self, PyObject *args) { 56 72 int raster; … … 100 116 static PyMethodDef CLoader_methods[] = { 101 117 { "to_string", (PyCFunction)to_string, METH_VARARGS, "Print the objects params" }, 102 {"load_data", (PyCFunction)load_data, METH_VARARGS, "Load the data into a numpy array"}, 118 { "get_filename", (PyCFunction)get_filename, METH_VARARGS, "Get the filename" }, 119 { "get_frame", (PyCFunction)get_frame, METH_VARARGS, "Get the frame that will be loaded" }, 120 { "get_n_pixels", (PyCFunction)get_n_pixels, METH_VARARGS, "Get n_pixels" }, 121 { "get_n_rasters", (PyCFunction)get_n_rasters, METH_VARARGS, "Get n_rasters" }, 122 { "load_data", (PyCFunction)load_data, METH_VARARGS, "Load the data into a numpy array" }, 103 123 {NULL} 104 124 };
Note: See TracChangeset
for help on using the changeset viewer.