diff --git a/.github/workflows/pypi-release.yml b/.github/workflows/pypi-release.yml new file mode 100644 index 0000000..8de3d0d --- /dev/null +++ b/.github/workflows/pypi-release.yml @@ -0,0 +1,74 @@ +name: Build and Upload PySP2 Release to PyPI +on: + release: + types: + - published + +jobs: + build-artifacts: + runs-on: ubuntu-latest + if: github.repository == 'ARM-DOE/PySP2' + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + - uses: actions/setup-python@v4 + name: Install Python + with: + python-version: 3.11 + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + python -m pip install setuptools setuptools-scm wheel twine check-manifest + - name: Build tarball and wheels + run: | + git clean -xdf + git restore -SW . + python -m build --sdist --wheel . + - name: Check built artifacts + run: | + python -m twine check dist/* + pwd + if [ -f dist/pysp2-0.0.0.tar.gz ]; then + echo "❌ INVALID VERSION NUMBER" + exit 1 + else + echo "✅ Looks good" + fi + - uses: actions/upload-artifact@v3 + with: + name: releases + path: dist + + test-built-dist: + needs: build-artifacts + runs-on: ubuntu-latest + steps: + - uses: actions/setup-python@v4 + name: Install Python + with: + python-version: "3.x" + - uses: actions/download-artifact@v3 + with: + name: releases + path: dist + - name: List contents of built dist + run: | + ls -ltrh + ls -ltrh dist + upload-to-pypi: + needs: test-built-dist + if: github.event_name == 'release' + runs-on: ubuntu-latest + steps: + - uses: actions/download-artifact@v3 + with: + name: releases + path: dist + - name: Publish package to PyPI + uses: pypa/gh-action-pypi-publish@v1.8.10 + with: + user: __token__ + password: ${{ secrets.PYPI_TOKEN }} + verbose: true \ No newline at end of file diff --git a/docs/environment_docs.yml b/docs/environment_docs.yml index 385ba2b..e591e8d 100644 --- a/docs/environment_docs.yml +++ b/docs/environment_docs.yml @@ -5,10 +5,11 @@ channels: dependencies: - act-atmos - xarray + - sphinx + - pydata-sphinx-theme - pip: - - sphinx - sphinx_gallery - sphinx-copybutton - - pydata-sphinx-theme<0.9.0 - sphinx_design - nbsphinx + - sphinxcontrib-applehelp<1.0.8 diff --git a/docs/source/_static/default.css b/docs/source/_static/default.css deleted file mode 100644 index 229041c..0000000 --- a/docs/source/_static/default.css +++ /dev/null @@ -1,146 +0,0 @@ -/* ACT style heading towards use of Poppins font */ -.header-style, h1, h2, h3, h4, h5, h6 { - font-family: Poppins, sans-serif; - } - - /* ARM header color */ - .bg-arm { - background-color: #182b55; - } - - :root { - --pst-color-navbar-link: 255, 255, 255; - --pst-color-text-base: 24, 43, 85; - --pst-color-h3: var(--pst-color-text-base); - --pst-color-h4: var(--pst-color-text-base); - --pst-color-h5: var(--pst-color-text-base); - --pst-color-h6: var(--pst-color-text-base); - --pst-color-paragraph: var(--pst-color-text-base); - } - -/* Override the default color set in the original theme for title */ -.navbar-brand>.title { - color: rgba(255, 255, 255) !important; - font-weight: 400 !important; - font-style: bold; -} - - /* Override the default color set in the original theme */ - .navbar-nav>.active>.nav-link { - color: rgba(255, 255, 255) !important; - font-weight: 400 !important; - font-style: italic; - } - - .fa-github-square:before { - color: rgba(255, 255, 255) !important; - font-weight: 400 !important; - } - - .fa-twitter-square:before { - color: rgba(255, 255, 255) !important; - font-weight: 400 !important; - } - - /* Override the default logo height */ - .navbar-brand { - height: 50px; - } - - /* Enhance the links to function docs in the gallery examples */ - div[class^="highlight"] a { - background-color: #EEEEEE; - } - - /* Control the appearance of the version alert banner */ - #banner .alert-version, .alert-news { - margin: 1em; - padding: 0.5em; - font-family: "Work Sans", sans-serif; - font-weight: 600; font-size: 16px; - } - - .intro-card { - background: #d8e5e8; - border: none; - border-radius: 0; - padding: 30px 10px 10px 10px; - margin: 10px 0px; - } - - .intro-card .card-text { - margin: 20px 0px; - } - - .card-button { - background-color: #fafafa; - border: none; - color: #484848; - text-align: center; - text-decoration: none; - display: inline-block; - font-size: 0.9rem; - border-radius: 0.5rem; - max-width: 220px; - padding: 0.5rem 0rem; - margin-top: auto; - } - - .card-button a { - color: #484848; - } - - .card-button p { - margin-top: 0; - margin-bottom: 0rem; - color: #484848; - } - - /* Tweaks to the appearance of the sidebars */ - .bd-sidebar { - flex: 0 0 20%; - border-right: none; - } - - .bd-toc .tocsection { - border-left: none; - } - - .bd-toc .section-nav { - border-left: none; - } - - /* Can remove once theme releases new version */ - /* xarray output display in bootstrap */ - .xr-wrap[hidden] { - display: block !important; - } - - .xr-var-data pre { - border: none; - box-shadow: none; - } - - - /* Styling the API Changes Table */ - .api-table tr:nth-child(3n + 1){ - background: #EEF5F5; - } - - .api-table tr:nth-child(3n + 2){ - opacity: 0.65; - } - - code.literal:not(.xref) span.pre { - color: #000; - } - - .api-table tr:nth-child(3n + 2)>td span:first-child::before{ - content: url(old.png); - zoom: 0.25; - } - - .api-table tr:nth-child(3n + 3)>td span:first-child::before{ - content: url(new.png); - zoom: 0.21; - } diff --git a/docs/source/_static/doc_shared.js b/docs/source/_static/doc_shared.js index 9d59448..8ab970f 100644 --- a/docs/source/_static/doc_shared.js +++ b/docs/source/_static/doc_shared.js @@ -1,4 +1,4 @@ -const project = "ACT"; +const project = "PySP2"; // Borrowed from Bokeh docs to look for a banner.html at the base of the docs repo and add that // to the banner if present. diff --git a/docs/source/_templates/layout.html b/docs/source/_templates/layout.html index a5e99e6..cfa4bfd 100644 --- a/docs/source/_templates/layout.html +++ b/docs/source/_templates/layout.html @@ -6,12 +6,3 @@ {{ super() }} {% endblock %} - -{% block docs_navbar %} - - -{# Added to support a banner with an alert #} - -{% endblock %} diff --git a/docs/source/conf.py b/docs/source/conf.py index b9593ab..78e68f6 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -72,9 +72,6 @@ napoleon_include_init_with_doc = False napoleon_use_param = False -# Add any paths that contain templates here, relative to this directory. -templates_path = ['_templates'] - # -- Options for HTML output ------------------------------------------------- # The theme to use for HTML and HTML Help pages. See the documentation for @@ -87,7 +84,7 @@ # so a file named "default.css" will overwrite the builtin "default.css". html_static_path = ['_static'] -html_css_files = ['default.css'] +html_css_files = ['act-theme.css'] html_js_files = ['doc_shared.js'] diff --git a/pysp2/__init__.py b/pysp2/__init__.py index 1070b21..12ed406 100644 --- a/pysp2/__init__.py +++ b/pysp2/__init__.py @@ -9,4 +9,4 @@ from . import vis from . import testing -__version__ = "1.3.3" +__version__ = "1.4.0" diff --git a/pysp2/io/read_hk.py b/pysp2/io/read_hk.py index 18735aa..54b47ab 100644 --- a/pysp2/io/read_hk.py +++ b/pysp2/io/read_hk.py @@ -26,7 +26,12 @@ def read_hk_file(file_name): hk_df: pandas.DataFrame The housekeeping information in a pandas DataFrame """ - my_df = act.io.read_csv(file_name, sep="\t") + + try: + my_df = act.io.csvfiles.read_csv(file_name, sep="\t") + except AttributeError: + my_df = act.io.text.read_csv(file_name, sep="\t") + # Parse time from filename start_time = pd.Timestamp('1904-01-01') my_df = my_df.rename({'index': 'time'}) diff --git a/pysp2/vis/plot_wave.py b/pysp2/vis/plot_wave.py index 17a2663..b753ea5 100644 --- a/pysp2/vis/plot_wave.py +++ b/pysp2/vis/plot_wave.py @@ -50,9 +50,9 @@ def plot_wave(ds, record_no, chn, plot_fit=True, if append_to_display is not False: display = append_to_display else: - display = act.plotting.HistogramDisplay(inp_data) + display = act.plotting.DistributionDisplay(inp_data) else: - display = act.plotting.HistogramDisplay(inp_data, **init_kwargs) + display = act.plotting.DistributionDisplay(inp_data, **init_kwargs) if 'subplot_index' in kwargs.keys(): ax = display.plot_size_distribution( 'Data_ch' + str(chn), bins, diff --git a/setup.py b/setup.py index c51f78a..a81d304 100644 --- a/setup.py +++ b/setup.py @@ -40,8 +40,8 @@ LICENSE = 'BSD' PLATFORMS = "Linux, Windows, OSX" MAJOR = 1 -MINOR = 3 -MICRO = 4 +MINOR = 4 +MICRO = 0 #SCRIPTS = glob.glob('scripts/*') #TEST_SUITE = 'nose.collector' diff --git a/tests/test_gfit.py b/tests/test_gfit.py index b8fc004..00511e2 100644 --- a/tests/test_gfit.py +++ b/tests/test_gfit.py @@ -29,8 +29,7 @@ def test_psds(): my_binary['ScatDiaBC50'].values[ScatRejectKey == 0]) < 1000. my_psds = pysp2.util.process_psds(my_binary, my_hk, my_ini) np.testing.assert_almost_equal(my_psds['NumConcIncan'].max(), 0.95805343) - np.testing.assert_almost_equal(my_binary['DeadtimeRelativeBias'].mean(), -0.00023515) - coeff, beam_profile = pysp2.util.beam_shape(my_binary,beam_position_from='peak maximum',Globals=pysp2.util.DMTGlobals()) - - - + np.testing.assert_almost_equal(my_psds['ScatNumEnsemble'].sum(), 254.773995310) + np.testing.assert_almost_equal(my_psds['IncanNumEnsemble'].sum(), 32.22939087) + np.testing.assert_almost_equal(my_psds['ScatMassEnsemble'].sum(), 3.15026266) + np.testing.assert_almost_equal(my_psds['IncanMassEnsemble'].sum(), 0.08177226)