Changeset 388bd51 in sasview for src/sas/sascalc/dataloader/readers


Ignore:
Timestamp:
Apr 4, 2017 9:21:31 AM (8 years ago)
Author:
Adam Washington <adam.washington@…>
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.2.2, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
Children:
09a0be5
Parents:
def97a0
Message:

Get sesans_reader utility functions out of the main namespace

Move the utility functions into the Reader class so that, if someone
performs an "import *", they won't pollute their namespace with some
private utility functions.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/sas/sascalc/dataloader/readers/sesans_reader.py

    rdef97a0 r388bd51  
    7474                    dy = data[:, 2] 
    7575 
    76                     lam_unit = _header_fetch(headers, "wavelength") 
     76                    lam_unit = self._header_fetch(headers, "wavelength") 
    7777                    if lam_unit == "AA": 
    7878                        lam_unit = "A" 
     
    8080                    x, x_unit = self._unit_conversion( 
    8181                        x, lam_unit, 
    82                         _fetch_unit(headers, "spin echo length")) 
     82                        self._fetch_unit(headers, "spin echo length")) 
    8383                    dx, dx_unit = self._unit_conversion( 
    8484                        dx, lam_unit, 
    85                         _fetch_unit(headers, "error SEL")) 
     85                        self._fetch_unit(headers, "error SEL")) 
    8686                    dlam, dlam_unit = self._unit_conversion( 
    8787                        dlam, lam_unit, 
    88                         _fetch_unit(headers, "error wavelength")) 
     88                        self._fetch_unit(headers, "error wavelength")) 
    8989                    y_unit = r'\AA^{-2} cm^{-1}' 
    9090 
     
    101101 
    102102                    output.sample.zacceptance = ( 
    103                         float(_header_fetch(params, "Q_zmax")), 
    104                         _fetch_unit(params, "Q_zmax")) 
     103                        float(self._header_fetch(params, "Q_zmax")), 
     104                        self._fetch_unit(params, "Q_zmax")) 
    105105 
    106106                    output.sample.yacceptance = ( 
    107                         float(_header_fetch(params, "Q_ymax")), 
    108                         _fetch_unit(params, "Q_ymax")) 
     107                        float(self._header_fetch(params, "Q_ymax")), 
     108                        self._fetch_unit(params, "Q_ymax")) 
    109109 
    110110                if len(output.x) < 1: 
     
    125125        return value, new_unit 
    126126 
     127    def _header_fetch(self, headers, key): 
     128        index = [k for k in headers.keys() 
     129                 if k.startswith(key)][0] 
     130        return headers[index] 
    127131 
    128 def _header_fetch(headers, key): 
    129     index = [k for k in headers.keys() 
    130              if k.startswith(key)][0] 
    131     return headers[index] 
    132  
    133  
    134 def _fetch_unit(params, key): 
    135     index = [k for k in params.keys() 
    136              if k.startswith(key)][0] 
    137     unit = index.strip().split()[-1][1:-1] 
    138     if unit.startswith(r"\A"): 
    139         unit = "1/A" 
    140     return unit 
     132    def _fetch_unit(self, params, key): 
     133        index = [k for k in params.keys() 
     134                 if k.startswith(key)][0] 
     135        unit = index.strip().split()[-1][1:-1] 
     136        if unit.startswith(r"\A"): 
     137            unit = "1/A" 
     138        return unit 
Note: See TracChangeset for help on using the changeset viewer.