Skip to content

Commit

Permalink
update to version 2.2
Browse files Browse the repository at this point in the history
  • Loading branch information
AStcherbinine committed Mar 6, 2021
1 parent 902830d commit 192a54b
Show file tree
Hide file tree
Showing 8 changed files with 138 additions and 33 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
![version](https://img.shields.io/badge/version-2.1-blue)
![pythonversion](https://img.shields.io/badge/Python-3.7-blue)
![version](https://img.shields.io/badge/version-2.2-blue)
![pythonversion](https://img.shields.io/badge/Python-3.7+-blue)

# OMEGA-Py : Python tools for OMEGA data

Expand Down Expand Up @@ -34,7 +34,7 @@ export OMEGA_PY_PATH="/data/mex-omegj/data1/omega_python/omegapy/"
~~~
*Adapt the path if needed, here is the default configuration for internal IAS use on the server.*

## Usage
## Basic usage
~~~python
# package importation
import omegapy.omega_data as od
Expand Down
12 changes: 8 additions & 4 deletions docs/doc.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
# OMEGA-Py documentation - v2.0
# OMEGA-Py documentation - v2.2

## [`omegapy.omega_data`](doc_omega_data.md)

Importation and correction of OMEGA/MEx observations from binaries files.

`class OMEGAdata(obs='', empty=False, data_path=_omega_bin_path, corrV=True, corrL=True, disp=True)`

`OMEGAdata.get_header_qub(data_path=_omega_bin_path)`

`OMEGAdata.get_header_nav(data_path=_omega_bin_path)`

`find_cube(lon0, lat0, cmin=0, cmax=10000, out=False)`

`autosave_omega(omega, folder='auto', base_folder=_omega_py_path, security=True, disp=True)`
Expand Down Expand Up @@ -65,13 +69,13 @@ Display of OMEGAdata cubes.

`show_omega(omega, lam, refl=True, lam_unit='m', cmap='Greys_r', vmin=None, vmax=None, title='auto', xlim=(None, None), ylim=(None, None), Nfig=None)`

`show_omega_v2(omega, lam, refl=True, lam_unit='m', cmap='Greys_r', vmin=None, vmax=None, alpha=None, title='auto', lonlim=(None, None), latlim=(None, None), Nfig=None, polar=False, cbar=True, grid=True, mask=None, negatives_longitudes='auto')`
`show_omega_v2(omega, lam, refl=True, lam_unit='m', cmap='Greys_r', vmin=None, vmax=None, alpha=None, title='auto', lonlim=(None, None), latlim=(None, None), Nfig=None, polar=False, cbar=True, grid=True, mask=None, negatives_longitudes='auto', **kwargs)`

`show_omega_interactif(omega, lam, refl=True, lam_unit='m', cmap='Greys_r', vmin=None, vmax=None, title='auto', autoyscale=True, xlim=(None, None), ylim=(None, None))`

`show_omega_interactif_v2(omega, lam=1.085, refl=True, lam_unit='m', data=None, cmap='Greys_r', cb_title='data', title='auto', vmin=None, vmax=None, autoyscale=True, ylim_sp=(None, None), alpha=None, lonlim=(None, None), latlim=(None, None), polar=False, cbar=True, grid=True, mask=None, lam_mask=None, negatives_longitudes='auto')`
`show_omega_interactif_v2(omega, lam=1.085, refl=True, lam_unit='m', data=None, cmap='Greys_r', cb_title='data', title='auto', vmin=None, vmax=None, autoyscale=True, ylim_sp=(None, None), alpha=None, lonlim=(None, None), latlim=(None, None), polar=False, cbar=True, grid=True, mask=None, lam_mask=None, negatives_longitudes='auto', **kwargs)`

`show_data_v2(omega, data, cmap='viridis', vmin=None, vmax=None, alpha=None, title='auto', cb_title = 'data', lonlim=(None, None), latlim=(None, None), Nfig=None, polar=False, cbar=True, grid=True, mask=None, negatives_longitudes='auto')`
`show_data_v2(omega, data, cmap='viridis', vmin=None, vmax=None, alpha=None, title='auto', cb_title = 'data', lonlim=(None, None), latlim=(None, None), Nfig=None, polar=False, cbar=True, grid=True, mask=None, negatives_longitudes='auto', **kwargs)`

`show_omega_list_v2(omega_list, lam=1.085, lat_min=-90, lat_max=90, lon_min=0, lon_max=360, pas_lat=0.1, pas_lon=0.1, cmap='Greys_r', vmin=None, vmax=None, title='auto', Nfig=None, polar=False, cbar=True, cb_title='auto', data_list=None, mask_list=None, negative_values=False, plot=True, grid=True, out=False, negatives_longitudes=False, **kwargs)`

Expand Down
36 changes: 35 additions & 1 deletion docs/doc_omega_data.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
# OMEGA-Py documentation - v2.0
# OMEGA-Py documentation - v2.2

## `omegapy.omega_data`

Importation and correction of OMEGA/MEx observations from binaries files.

`class OMEGAdata(obs='', empty=False, data_path=_omega_bin_path, corrV=True, corrL=True, disp=True)`

`OMEGAdata.get_header_qub(data_path=_omega_bin_path)`

`OMEGAdata.get_header_nav(data_path=_omega_bin_path)`

`find_cube(lon0, lat0, cmin=0, cmax=10000, out=False)`

`autosave_omega(omega, folder='auto', base_folder=_omega_py_path, security=True, disp=True)`
Expand Down Expand Up @@ -199,6 +203,36 @@ class omegapy.omega_data.OMEGAdata(obs='', empty=False, data_path=_omega_bin_pat
__eq__(self, other)

__repr__(self)

get_header_qub(self, data_path=_omega_bin_path)
Return the data from the header of the .QUB file, as a dictionary.

See the OMEGA ECAID for informations about the header entries.

Parameters
==========
data_path : str, optional (default _omega_py_path)
The path of the directory containing the data (.QUB) files.

Returns
=======
hd_qub : dict
Dictionary containing the data from the ORBXXXX_X.QUB file.

get_header_nav(self, data_path=_omega_bin_path)
Return the data from the header of the .NAV file, as a dictionary.

See the OMEGA ECAID for informations about the header entries.

Parameters
==========
data_path : str, optional (default _omega_py_path)
The path of the directory containing the navigation (.NAV) files.

Returns
=======
hd_nav : dict
Dictionary containing the data from the ORBXXXX_X.NAV file.
~~~

### Observation search
Expand Down
22 changes: 15 additions & 7 deletions docs/doc_omega_plots.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
# OMEGA-Py documentation - v2.0
# OMEGA-Py documentation - v2.2

## `omegapy.omega_plots`

Display of OMEGAdata cubes.

`show_omega(omega, lam, refl=True, lam_unit='m', cmap='Greys_r', vmin=None, vmax=None, title='auto', xlim=(None, None), ylim=(None, None), Nfig=None)`

`show_omega_v2(omega, lam, refl=True, lam_unit='m', cmap='Greys_r', vmin=None, vmax=None, alpha=None, title='auto', lonlim=(None, None), latlim=(None, None), Nfig=None, polar=False, cbar=True, grid=True, mask=None, negatives_longitudes='auto')`
`show_omega_v2(omega, lam, refl=True, lam_unit='m', cmap='Greys_r', vmin=None, vmax=None, alpha=None, title='auto', lonlim=(None, None), latlim=(None, None), Nfig=None, polar=False, cbar=True, grid=True, mask=None, negatives_longitudes='auto', **kwargs)`

`show_omega_interactif(omega, lam, refl=True, lam_unit='m', cmap='Greys_r', vmin=None, vmax=None, title='auto', autoyscale=True, xlim=(None, None), ylim=(None, None))`

`show_omega_interactif_v2(omega, lam=1.085, refl=True, lam_unit='m', data=None, cmap='Greys_r', cb_title='data', title='auto', vmin=None, vmax=None, autoyscale=True, ylim_sp=(None, None), alpha=None, lonlim=(None, None), latlim=(None, None), polar=False, cbar=True, grid=True, mask=None, lam_mask=None, negatives_longitudes='auto')`
`show_omega_interactif_v2(omega, lam=1.085, refl=True, lam_unit='m', data=None, cmap='Greys_r', cb_title='data', title='auto', vmin=None, vmax=None, autoyscale=True, ylim_sp=(None, None), alpha=None, lonlim=(None, None), latlim=(None, None), polar=False, cbar=True, grid=True, mask=None, lam_mask=None, negatives_longitudes='auto', **kwargs)`

`show_data_v2(omega, data, cmap='viridis', vmin=None, vmax=None, alpha=None, title='auto', cb_title = 'data', lonlim=(None, None), latlim=(None, None), Nfig=None, polar=False, cbar=True, grid=True, mask=None, negatives_longitudes='auto')`
`show_data_v2(omega, data, cmap='viridis', vmin=None, vmax=None, alpha=None, title='auto', cb_title = 'data', lonlim=(None, None), latlim=(None, None), Nfig=None, polar=False, cbar=True, grid=True, mask=None, negatives_longitudes='auto', **kwargs)`

`show_omega_list_v2(omega_list, lam=1.085, lat_min=-90, lat_max=90, lon_min=0, lon_max=360, pas_lat=0.1, pas_lon=0.1, cmap='Greys_r', vmin=None, vmax=None, title='auto', Nfig=None, polar=False, cbar=True, cb_title='auto', data_list=None, mask_list=None, negative_values=False, plot=True, grid=True, out=False, negatives_longitudes=False, **kwargs)`

Expand Down Expand Up @@ -64,7 +64,8 @@ omegapy.omega_plots.show_omega(omega, lam, refl=True, lam_unit='m', cmap='Greys_
~~~python
omegapy.omega_plots.show_omega_v2(omega, lam, refl=True, lam_unit='m', cmap='Greys_r', vmin=None, vmax=None,
alpha=None, title='auto', lonlim=(None, None), latlim=(None, None), Nfig=None,
polar=False, cbar=True, grid=True, mask=None, negatives_longitudes='auto'):
polar=False, cbar=True, grid=True, mask=None, negatives_longitudes='auto',
**kwargs):
Display an OMEGA/MEx observation with respect of the lat/lon coordinates of the pixels,
and allows to use a polar projection if desired.

Expand Down Expand Up @@ -113,6 +114,8 @@ omegapy.omega_plots.show_omega_v2(omega, lam, refl=True, lam_unit='m', cmap='Gre
| True -> longitudes between 0° and 360°.
| False -> longitudus between -180° and 180°.
| 'auto' -> automatic detection of the best case.
**kwargs:
Optional arguments for the plt.pcolormesh() function.
~~~

### Display cube interactive version
Expand Down Expand Up @@ -158,7 +161,7 @@ omegapy.omega_plots.show_omega_interactif_v2(omega, lam=1.085, refl=True, lam_un
vmin=None, vmax=None, autoyscale=True, ylim_sp=(None, None),
alpha=None, lonlim=(None, None), latlim=(None, None),
polar=False, cbar=True, grid=True, mask=None, lam_mask=None,
negatives_longitudes='auto'):
negatives_longitudes='auto', **kwargs):
Affichage interactif d'un cube de données.
Possibilité d'afficher le spectre associé à un pixel en cliquant dessus
(maintenir Ctrl pour supperposer plusieurs spectres), ou en se déplaçant avec les flèches.
Expand Down Expand Up @@ -226,14 +229,17 @@ omegapy.omega_plots.show_omega_interactif_v2(omega, lam=1.085, refl=True, lam_un
| True -> longitudes between 0° and 360°.
| False -> longitudus between -180° and 180°.
| 'auto' -> automatic detection of the best case.
**kwargs:
Optional arguments for the plt.pcolormesh() function.
~~~

### Display derived high-level data map from OMEGA observation

~~~python
omegapy.omega_plots.show_data_v2(omega, data, cmap='viridis', vmin=None, vmax=None, alpha=None, title='auto',
cb_title = 'IBD', lonlim=(None, None), latlim=(None, None), Nfig=None,
polar=False, cbar=True, grid=True, mask=None, negatives_longitudes='auto'):
polar=False, cbar=True, grid=True, mask=None, negatives_longitudes='auto',
**kwargs):
Affichage données haut-niveau avec pcolormesh.
Display an OMEGA/MEx observation with respect of the lat/lon coordinates of the pixels,
and allows to use a polar projection if desired.
Expand Down Expand Up @@ -278,6 +284,8 @@ omegapy.omega_plots.show_data_v2(omega, data, cmap='viridis', vmin=None, vmax=No
| True -> longitudes between 0° and 360°.
| False -> longitudus between -180° and 180°.
| 'auto' -> automatic detection of the best case.
**kwargs:
Optional arguments for the plt.pcolormesh() function.
~~~

### Display composite map of several OMEGA observations, sample on a lat/lon grid
Expand Down
2 changes: 1 addition & 1 deletion docs/doc_useful_functions.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# OMEGA-Py documentation - v2.0
# OMEGA-Py documentation - v2.2

## `omegapy.useful_functions`

Expand Down
61 changes: 55 additions & 6 deletions omegapy/omega_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

## omega_data.py
## Created by Aurélien STCHERBININE
## Last modified by Aurélien STCHERBININE : 15/02/2021
## Last modified by Aurélien STCHERBININE : 06/03/2021

##----------------------------------------------------------------------------------------
"""Importation and correction of OMEGA/MEx observations from binaries files.
Expand Down Expand Up @@ -34,7 +34,7 @@

# Name of the current file
_py_file = 'omega_data.py'
_Version = 2.1
_Version = 2.2

# Path of the package files
package_path = os.path.abspath(os.path.dirname(__file__))
Expand Down Expand Up @@ -687,6 +687,8 @@ def ordcorr(lam, sp):
saturation_vis = idat[:, 299, :] / summation
# Temperature voie C
temperature = sdat1[0, 2, :] * 0.001
# Temperature voie L
# temperature = sdat1[1, 2, :] * 0.001

#--------------------------
# Output data
Expand Down Expand Up @@ -947,7 +949,7 @@ def __init__(self, obs='', empty=False, data_path=_omega_bin_path, corrV=True, c
cube_i2 = np.swapaxes(cube_i, 1, 2)
cube_rf2 = np.swapaxes(cube_rf, 1, 2)
# Observation UTC date & time
Y, M, D, h, m, s = np.average(utc[:,:6], axis=0).astype(np.int64)
Y, M, D, h, m, s = np.median(utc[:,:6], axis=0).astype(np.int64)
utc_dt = datetime.datetime(Y, M, D, h, m, s)
# Longitude pixels grid
ny, nx = lon.shape
Expand Down Expand Up @@ -1194,6 +1196,44 @@ def __repr__(self):
\033[3m{7}\033[0m""".format(self.name, self.version, self.ls, self.my, self.data_quality,
self.therm_corr, self.atm_corr, self.add_infos)
return description

def get_header_qub(self, data_path=_omega_bin_path):
"""Return the data from the header of the .QUB file, as a dictionary.
See the OMEGA ECAID for informations about the header entries.
Parameters
==========
data_path : str, optional (default _omega_py_path)
The path of the directory containing the data (.QUB) files.
Returns
=======
hd_qub : dict
Dictionary containing the data from the ORBXXXX_X.QUB file.
"""
qub_path = os.path.join(data_path, self.name+'.QUB')
hd_qub = _read_header(qub_path)
return hd_qub

def get_header_nav(self, data_path=_omega_bin_path):
"""Return the data from the header of the .NAV file, as a dictionary.
See the OMEGA ECAID for informations about the header entries.
Parameters
==========
data_path : str, optional (default _omega_py_path)
The path of the directory containing the navigation (.NAV) files.
Returns
=======
hd_nav : dict
Dictionary containing the data from the ORBXXXX_X.NAV file.
"""
nav_path = os.path.join(data_path, self.name+'.NAV')
hd_nav = _read_header(nav_path)
return hd_nav

##-----------------------------------------------------------------------------------
## Recherche observation
Expand Down Expand Up @@ -1401,12 +1441,20 @@ class F_Qube_nav(ctypes.Structure):
phas = geocube[i0, 10, j0] * 1e-4
slant = geocube[i0, 11, j0] * 1e-3
alt = geocube[i0, 12, j0] * 1e-3
Y, M, D, h, m, s = geocube[:6, 1, j0]
utc_dt = datetime.datetime(Y, M, D, h, m, s)
possible_geom_corruption = False
try:
Y, M, D, h, m, s = geocube[:6, 1, j0]
utc_dt = datetime.datetime(Y, M, D, h, m, s)
except: # Possible corruption of some geometry lines
Y, M, D, h, m, s = np.median(geocube[:6, 1, :], axis=1).astype(np.int64)
utc_dt = datetime.datetime(Y, M, D, h, m, s)
possible_geom_corruption = True
my = _utc_to_my(utc_dt)
loct = _compute_local_time(longa, sslong)[i0, j0]
obs_output = '{0:9s}{1:6d}{2:6d}{3:8.2f}{4:9.1f}{5:8.2f}{6:8.2f}{7:8.2f}{8:8.2f}{9:8.2f}{10:4d}'.format(
nomc[n], i0, j0, distmin, slant, inci, emer, phas, loct, solong, my)
if possible_geom_corruption:
obs_output = '\033[3m' + obs_output + '\033[0m'
print(obs_output)

with open(path_cubliste, 'a') as f_cublist:
Expand Down Expand Up @@ -1606,7 +1654,8 @@ def autoload_omega(obs_name, folder='auto', version=_Version, base_folder=_omega
excl.append('atm')
filename = '*{name}*{corr_ext}*.pkl'.format(name=obs_name, corr_ext=ext)
if folder == 'auto':
folder = 'v' + str(int(version))
Mversion = int(version)
folder = 'v' + str(Mversion)
filename2 = uf.myglob(os.path.join(base_folder, folder, filename), exclude=excl)
if filename2 is None:
if (therm_corr in [None, False]) and (atm_corr in [None, False]):
Expand Down
Loading

0 comments on commit 192a54b

Please sign in to comment.