Skip to content

Commit

Permalink
Reorganised and simplified thermolib, ogcwms, and netCDF4tools. (#1132)
Browse files Browse the repository at this point in the history
See #1131
  • Loading branch information
joernu76 authored Aug 6, 2021
1 parent 3b3608f commit 51fa287
Show file tree
Hide file tree
Showing 20 changed files with 146 additions and 312 deletions.
147 changes: 0 additions & 147 deletions mslib/_tests/test_thermolib.py

This file was deleted.

9 changes: 4 additions & 5 deletions mslib/msui/flighttrack.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,12 @@

from PyQt5 import QtGui, QtCore, QtWidgets

from mslib.msui.mss_qt import variant_to_string, variant_to_float
from mslib.utils.units import units
from mslib import utils, __version__
from mslib import thermolib
from mslib.utils import config_loader, find_location, save_settings_qsettings, load_settings_qsettings
from mslib.msui.performance_settings import DEFAULT_PERFORMANCE
from mslib.utils.units import units
from mslib.utils import thermolib, config_loader, find_location, save_settings_qsettings, load_settings_qsettings
from mslib.msui import MissionSupportSystemDefaultConfig as mss_default
from mslib.msui.mss_qt import variant_to_string, variant_to_float
from mslib.msui.performance_settings import DEFAULT_PERFORMANCE

from mslib.utils import writexml
xml.dom.minidom.Element.writexml = writexml
Expand Down
6 changes: 3 additions & 3 deletions mslib/msui/mpl_pathinteractor.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@
import matplotlib.path as mpath
import matplotlib.patches as mpatches
from PyQt5 import QtCore, QtWidgets
from mslib.utils.units import units
from mslib.utils import get_distance, find_location, path_points, latlon_points
from mslib.thermolib import pressure2flightlevel

from mslib.utils import get_distance, find_location, path_points, latlon_points
from mslib.utils.units import units
from mslib.utils.thermolib import pressure2flightlevel
from mslib.msui import flighttrack as ft


Expand Down
7 changes: 3 additions & 4 deletions mslib/msui/mpl_qtwidget.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,13 @@
from matplotlib import cbook, figure
from matplotlib.backends.backend_qt5agg import NavigationToolbar2QT, FigureCanvasQTAgg
import matplotlib.backend_bases
from PyQt5 import QtCore, QtWidgets, QtGui

from mslib.utils import thermolib, config_loader, FatalUserError, convert_pressure_to_vertical_axis_measure
from mslib.utils.units import units
from mslib import thermolib
from mslib.utils import config_loader, FatalUserError
from mslib.msui import mpl_pathinteractor as mpl_pi
from mslib.msui import mpl_map
from mslib.msui.icons import icons
from PyQt5 import QtCore, QtWidgets, QtGui
from mslib.utils import convert_pressure_to_vertical_axis_measure

PIL_IMAGE_ORIGIN = "upper"
LAST_SAVE_DIRECTORY = config_loader(dataset="data_dir")
Expand Down
5 changes: 2 additions & 3 deletions mslib/msui/sideview.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,13 @@

from PyQt5 import QtGui, QtWidgets

from mslib.utils.units import units, convert_to
from mslib.utils import config_loader, save_settings_qsettings, load_settings_qsettings
from mslib.msui.mss_qt import ui_sideview_window as ui
from mslib.msui.mss_qt import ui_sideview_options as ui_opt
from mslib.msui.viewwindows import MSSMplViewWindow
from mslib.msui import wms_control as wms
from mslib.msui.icons import icons
from mslib import thermolib
from mslib.utils import thermolib, config_loader, save_settings_qsettings, load_settings_qsettings
from mslib.utils.units import units, convert_to

# Dock window indices.
WMS = 0
Expand Down
18 changes: 9 additions & 9 deletions mslib/msui/wms_control.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,18 +41,17 @@
from mslib.utils import config_loader
from PyQt5 import QtCore, QtGui, QtWidgets

import mslib.ogcwms
import owslib.util
from owslib.crs import axisorder_yx
from PIL import Image, ImageOps

from mslib.msui import constants, wms_capabilities
from mslib.msui.mss_qt import ui_wms_dockwidget as ui
from mslib.msui.mss_qt import ui_wms_password_dialog as ui_pw
from mslib.msui import wms_capabilities
from mslib.msui import constants
from mslib.utils import parse_iso_datetime, parse_iso_duration, load_settings_qsettings, save_settings_qsettings, Worker
from mslib.ogcwms import openURL, removeXMLNamespace
from mslib.msui.multilayers import Multilayers, Layer
from mslib.utils import (
ogcwms, parse_iso_datetime, parse_iso_duration, load_settings_qsettings,
save_settings_qsettings, Worker)


WMS_SERVICE_CACHE = {}
Expand All @@ -65,7 +64,7 @@ def add_wms_urls(combo_box, url_list):
combo_box.addItem(url)


class MSSWebMapService(mslib.ogcwms.WebMapService):
class MSSWebMapService(ogcwms.WebMapService):
"""Overloads the getmap() method of owslib.wms.WebMapService:
added parameters are
Expand Down Expand Up @@ -201,8 +200,8 @@ def getmap(self, layers=None, styles=None, srs=None, bbox=None,
# not considered. For some reason, the check below doesn't work, though..
proxies = config_loader(dataset="proxies")

u = openURL(base_url, data, method,
username=self.auth.username, password=self.auth.password, proxies=proxies)
u = ogcwms.openURL(base_url, data, method,
username=self.auth.username, password=self.auth.password, proxies=proxies)

# check for service exceptions, and return
# NOTE: There is little bug in owslib.util.openURL -- if the file
Expand All @@ -215,7 +214,8 @@ def getmap(self, layers=None, styles=None, srs=None, bbox=None,
se_xml = u.read()
se_tree = etree.fromstring(se_xml)
# Remove namespaces in the response, otherwise this code might fail
removeXMLNamespace(se_tree)
# (mslib) add ogcwms
ogcwms.removeXMLNamespace(se_tree)
err_message = str(se_tree.find('ServiceException').text).strip()
raise owslib.util.ServiceException(err_message, se_xml)
return u
Expand Down
2 changes: 1 addition & 1 deletion mslib/mswms/dataaccess.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
import numpy as np
import pint

from mslib import netCDF4tools
from mslib.utils import netCDF4tools
from mslib.utils.units import units


Expand Down
2 changes: 1 addition & 1 deletion mslib/mswms/mpl_hsec_styles.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@

from mslib.mswms.mpl_hsec import MPLBasemapHorizontalSectionStyle
from mslib.mswms.utils import Targets, get_style_parameters, get_cbar_label_format, make_cbar_labels_readable
from mslib import thermolib
from mslib.utils import thermolib
from mslib.utils.units import convert_to


Expand Down
2 changes: 1 addition & 1 deletion mslib/mswms/mpl_lsec_styles.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
import numpy as np

from mslib.mswms.mpl_lsec import AbstractLinearSectionStyle
import mslib.thermolib as thermolib
import mslib.utils.thermolib as thermolib
from mslib.utils.units import convert_to


Expand Down
2 changes: 1 addition & 1 deletion mslib/mswms/mpl_vsec_styles.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@

from mslib.mswms.mpl_vsec import AbstractVerticalSectionStyle
from mslib.mswms.utils import Targets, get_style_parameters, get_cbar_label_format, make_cbar_labels_readable
from mslib.utils import thermolib
from mslib.utils.units import convert_to
from mslib import thermolib


class VS_TemperatureStyle_01(AbstractVerticalSectionStyle):
Expand Down
2 changes: 1 addition & 1 deletion mslib/mswms/mss_plot_driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@

import numpy as np

from mslib import netCDF4tools
from mslib.utils import netCDF4tools
from mslib import utils


Expand Down
6 changes: 3 additions & 3 deletions mslib/plugins/io/flitestar.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@

import numpy as np
import os
from metpy.units import units
from fs import open_fs

import mslib.msui.flighttrack as ft
from mslib import thermolib
from fs import open_fs
from mslib.utils import thermolib
from mslib.utils.units import units


def load_from_flitestar(filename):
Expand Down
7 changes: 4 additions & 3 deletions mslib/plugins/io/text.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,14 @@
from builtins import str

import logging
from metpy.units import units
import codecs
import mslib.msui.flighttrack as ft
from mslib import thermolib
import os
from fs import open_fs

import mslib.msui.flighttrack as ft
from mslib.utils.units import units
from mslib.utils import thermolib


def save_to_txt(filename, name, waypoints):
if not filename:
Expand Down
9 changes: 4 additions & 5 deletions mslib/retriever.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,15 @@
import requests
from fs import open_fs
import PIL.Image
from metpy.units import units
import matplotlib.pyplot as plt

import mslib
import mslib.utils
from mslib.utils import thermolib
from mslib.utils.units import units
import mslib.msui
import mslib.msui.mpl_map
import mslib.msui.mss_qt
import mslib.thermolib

import matplotlib.pyplot as plt


TEXT_CONFIG = {
Expand Down Expand Up @@ -144,7 +143,7 @@ def main():
params["basemap"].update(config["predefined_map_sections"][section]["map"])
wps = load_from_ftml(filename)
wp_lats, wp_lons, wp_locs = [[x[i] for x in wps] for i in [0, 1, 3]]
wp_presss = [mslib.thermolib.flightlevel2pressure(wp[2] * units.hft).magnitude for wp in wps]
wp_presss = [thermolib.flightlevel2pressure(wp[2] * units.hft).magnitude for wp in wps]
for url, layer, style, elevation in config["automated_plotting"]["hsecs"]:
fig.clear()
ax = fig.add_subplot(111, zorder=99)
Expand Down
5 changes: 3 additions & 2 deletions mslib/utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,11 @@
except ImportError:
import pyproj

from PyQt5 import QtCore, QtWidgets, QtGui

from mslib.msui import constants, MissionSupportSystemDefaultConfig
from mslib.utils.units import units as _units
from mslib.thermolib import pressure2flightlevel
from PyQt5 import QtCore, QtWidgets, QtGui
from mslib.utils.thermolib import pressure2flightlevel
from mslib.msui.constants import MSS_CONFIG_PATH


Expand Down
Loading

0 comments on commit 51fa287

Please sign in to comment.