| Conditions | 2 |
| Total Lines | 26 |
| Code Lines | 6 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 1 |
| CRAP Score | 4.3145 |
| Changes | 0 | ||
| 1 | # -*- coding: utf-8 -*- |
||
| 19 | 1 | def read_akm(filename, nalt, nlat): |
|
| 20 | """Read SCIAMACHY level 2 averaging kernels into numpy array |
||
| 21 | |||
| 22 | Supports plain ascii (text) tables using :func:`numpy.genfromtxt` |
||
| 23 | and netcdf files using :mod:`xarray`. |
||
| 24 | |||
| 25 | Parameters |
||
| 26 | ---------- |
||
| 27 | filename: str |
||
| 28 | Filename of the averaging kernel elements |
||
| 29 | nalt: int |
||
| 30 | Number of altitude bins of the retrieval |
||
| 31 | nlat: int |
||
| 32 | Number of latitude bins of the retrieval |
||
| 33 | |||
| 34 | Returns |
||
| 35 | ------- |
||
| 36 | akm: numpy.ndarray of shape (nalt, nlat, nalt, nlat) |
||
| 37 | The averaging kernel matrix elements. |
||
| 38 | """ |
||
| 39 | try: |
||
| 40 | akm = np.genfromtxt(filename) |
||
| 41 | except UnicodeDecodeError: |
||
| 42 | # most probably a netcdf file |
||
| 43 | akm = xr.open_dataarray(filename).data |
||
| 44 | return akm.reshape(nalt, nlat, nalt, nlat) |
||
| 45 |