Changeset c3f0114 in sasview
- Timestamp:
- Aug 5, 2016 7:35:03 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:
- 535e181
- Parents:
- 6eaf89ea
- Location:
- src/sas/sascalc/file_converter
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/sascalc/file_converter/bsl_loader.py
r6eaf89ea rc3f0114 21 21 22 22 while True: 23 import pdb; pdb.set_trace()24 23 metadata = header_file.readline().strip() 25 24 metadata = metadata.split() … … 43 42 except: 44 43 is_valid = False 45 err_msg = "Invalid metadata in header file for {}".format(filename.replace('0.', '1.')) 44 err_msg = "Invalid metadata in header file for {}" 45 err_msg = err_msg.format(filename.replace('0.', '1.')) 46 46 break 47 47 -
src/sas/sascalc/file_converter/c_ext/bsl_loader.c
r6eaf89ea rc3f0114 25 25 const int n_rasters; 26 26 const int swap_bytes; 27 27 28 if (self != NULL) { 28 29 if (!PyArg_ParseTuple(args, "siiii", &filename, &frame, &n_pixels, &n_rasters, &swap_bytes)) … … 57 58 } 58 59 60 /* ----- Setters and Getters ----- */ 61 59 62 static PyObject *get_filename(CLoader *self, PyObject *args) { 60 63 return Py_BuildValue("s", self->params.filename); … … 121 124 return Py_BuildValue("i", self->params.swap_bytes); 122 125 } 126 127 /* ----- Instance Methods ----- */ 123 128 124 129 float reverse_float(const float in_float){ … … 141 146 int size[2] = {self->params.n_rasters, self->params.n_pixels}; 142 147 float cur_val; 143 PyObject *read_val;144 148 FILE *input_file; 145 149 PyArrayObject *data; 146 150 147 printf("load_data called\n");148 149 151 if (!PyArg_ParseTuple(args, "O!", &PyArray_Type, &data)) { 150 printf("Failed parsing PyArray object");151 152 return NULL; 152 153 } … … 154 155 input_file = fopen(self->params.filename, "rb"); 155 156 if (!input_file) { 156 printf("Failed opening file\n"); 157 return NULL; 158 } 159 160 printf("Calculating frame_pos\n"); 157 return NULL; 158 } 159 161 160 frame_pos = self->params.n_pixels * self->params.n_rasters * self->params.frame; 162 printf("frame_pos: %d\n", frame_pos);163 161 fseek(input_file, frame_pos*sizeof(float), SEEK_SET); 164 printf("fseek completed\n");165 162 166 163 for (raster = 0; raster < self->params.n_rasters; raster++) { … … 170 167 cur_val = reverse_float(cur_val); 171 168 PyArray_SETITEM(data, PyArray_GETPTR2(data, raster, pixel), PyFloat_FromDouble(cur_val)); 172 read_val = PyArray_GETITEM(data, PyArray_GETPTR2(data, raster, pixel));173 169 } 174 170 } 175 printf("Data read.\n");176 171 177 172 fclose(input_file); 178 printf("File closed\n");179 173 Py_DECREF(data); 180 printf("Function completed\n"); 174 181 175 return Py_BuildValue("O", data); 182 176 } 177 178 /* ----- Class Registration ----- */ 183 179 184 180 static PyMethodDef CLoader_methods[] = {
Note: See TracChangeset
for help on using the changeset viewer.