diff --git a/README.md b/README.md index aca31fe..634ae07 100644 --- a/README.md +++ b/README.md @@ -15,4 +15,6 @@

-An open source scientific article created using the [showyourwork](https://github.com/showyourwork/showyourwork) workflow. +*This is an automatically generated test for [showyourwork](https://github.com/showyourwork/showyourwork) generated from the file [test_zenodo.py](https://github.com/showyourwork/showyourwork/blob/main/tests/integration/test_zenodo.py).* + +Test a repo that downloads data from Zenodo. diff --git a/showyourwork.yml b/showyourwork.yml index 8c6fef2..95ac725 100644 --- a/showyourwork.yml +++ b/showyourwork.yml @@ -1,105 +1,67 @@ -# Enable rule caching on Zenodo? cache_on_zenodo: true - -# Workflow graph (DAG) generation dag: - # Generate `dag.pdf` on each build? - render: false - # Graphviz layout engine engine: sfdp - # Group files by type into plates? - group_by_type: false - # Custom graph attributes graph_attr: - ranksep: "1" - nodesep: "0.65" - # Custom node attributes + nodesep: '0.65' + ranksep: '1' + group_by_type: false node_attr: - shape: "box" - penwidth: "2" - width: "1" - # Files and glob patterns to ignore - # ignore_files: - # - src/tex/orcid-ID.png - - -# Externally-hosted datasets, e.g. on Zenodo + penwidth: '2' + shape: box + width: '1' + render: false datasets: - # 10.5281/zenodo.6468327: - # contents: - # TOI640b.json: src/data/TOI640b.json - -# Custom file dependencies + 10.5281/zenodo.6515864: + contents: + README.md: null + TOI640b.json: src/data/TOI640/planet.json + images.tar.gz: + README.md: null + S06: + image.json: src/data/TOI640/S06.json + S07: + image.json: src/data/TOI640/S07.json + lightcurves.zip: + lightcurves: + README.md: null + S06: + lc.txt: src/data/TOI640/S06.txt + S07: + lc.txt: src/data/TOI640/S07.txt + destination: src/data/TOI640 dependencies: - # src/scripts/my_script.py: - # - src/data/dataset_for_my_script.dat - # src/tex/ms.tex: - # - src/tex/stylesheet.tex - -# Name of the `.tex` manuscript and corresponding `.pdf` article + src/scripts/test_figure.py: + - src/data/TOI640/planet.json + - src/data/TOI640/S06.txt + - src/data/TOI640/S06.json + - src/data/TOI640/S07.txt + - src/data/TOI640/S07.json ms_name: ms - -# Optimize DAG by removing unnecessary jobs upstream of cache hits? optimize_caching: false - -# Overleaf sync settings overleaf: - # Overleaf project ID (blank = disabled) - id: - # Perform sync on GitHub Actions? gh_actions_sync: true - # List of files to push to Overleaf - push: - - src/tex/figures - - src/tex/output - # List of files to pull from Overleaf + id: null pull: - - src/tex/ms.tex - - src/tex/bib.bib - -# Always require all input files to be present on disk for workflow to pass? + - src/tex/ms.tex + - src/tex/bib.bib + push: + - src/tex/figures + - src/tex/output require_inputs: true - -# Allow cacheable rules to run on GitHub Actions? run_cache_rules_on_ci: false - -# Mapping of script file extensions to instructions for executing them scripts: py: python {script} - -# Display of the `showyourwork` stamp on first page stamp: - # Show the stamp? - enabled: true - # Stamp angle in degrees angle: -20.0 - # Stamp size in inches + enabled: true size: 0.75 - # Horizontal position in inches from right edge of paper - xpos: 0.50 - # Vertical position in inches from top edge of paper - ypos: 0.50 - # Display of the repo URL in the stamp url: - # Show the URL? enabled: true - # Maximum URL length to display maxlen: 40 - -# Enable SyncTeX? -synctex: True - -# Command-line options to be passed to tectonic when building the manuscript + xpos: 0.5 + ypos: 0.5 +synctex: true tectonic_args: [] - -# Preprocessing script for arXiv tarball -# (such as to switch `minted` from `finalizecache` to `frozencache`) -# The script will be passed a directory containing the manuscript source -# as input, and should modify the contents of that directory in-place. -# preprocess_arxiv_script: my_preprocess_script.sh - -# Enable verbose output? verbose: false - -# Version of `showyourwork` used to create this workflow version: 0.4.4.dev45+gaa3c043 + diff --git a/src/scripts/test_figure.py b/src/scripts/test_figure.py new file mode 100644 index 0000000..65f116d --- /dev/null +++ b/src/scripts/test_figure.py @@ -0,0 +1,64 @@ + +import matplotlib.pyplot as plt +import numpy as np +import json +import paths + +# Set up the figure +fig = plt.figure(figsize=(7, 6)) +ax = fig.subplot_mosaic( + ''' + AB + CC + ''' +) +fig.subplots_adjust(wspace=0.1, hspace=0.15) + +# Images +for n, dataset in zip(["A", "B"], ["S06", "S07"]): + with open(paths.data / "TOI640" / f"{dataset}.json", "r") as f: + image_data = json.load(f) + aperture = np.array(image_data["aperture"]) + image = np.array(image_data["image"]) / 1e3 + im = ax[n].imshow(image, origin="lower", vmin=0, vmax=4) + ax[n].set_xticks([]) + ax[n].set_yticks([]) + ax[n].set_title(dataset) + ax[n].set_aspect("auto") +fig.colorbar(im, ax=[ax["A"], ax["B"]], shrink=1, label="flux [ke$^-$/s]") + +# Dummy colorbar to get the spacing right +cbar = fig.colorbar(im, ax=ax["C"], shrink=1) +cbar.ax.set_visible(False) + +# Load planet data +with open(paths.data / "TOI640" / "planet.json", "r") as f: + planet_data = json.load(f) +phase = planet_data["phase"] +period = planet_data["period"] + +# Photometry +for dataset in ["S06", "S07"]: + + # Load the data + time, flux, *_ = np.loadtxt(paths.data / "TOI640" / f"{dataset}.txt").T + + # Divide out the rolling 1-day median baseline + dt = np.median(np.diff(time)) + w = int(1 / dt) + baseline = [np.median(flux[a : a + w]) for a in range(len(flux))] + flux /= baseline + + # Fold the data + time = (time % period) / period + phase + + # Plot it + ax["C"].plot(time, flux, ".", label=dataset) + +# Format the figure +ax["C"].legend() +ax["C"].set_xlim(-0.1, 0.1) +ax["C"].set_xlabel("orbital phase") +ax["C"].set_ylabel("normalized flux") +fig.savefig(paths.figures / "test_figure.pdf", bbox_inches="tight", dpi=300) + diff --git a/src/tex/ms.tex b/src/tex/ms.tex index 6ab8e9c..e200052 100644 --- a/src/tex/ms.tex +++ b/src/tex/ms.tex @@ -54,4 +54,14 @@ \section{Introduction} \bibliography{bib} +\begin{figure}[ht!] +\script{test_figure.py} +\begin{centering} +\includegraphics[width=\linewidth]{figures/test_figure.pdf} +\caption{A test figure.} +\label{fig:test_figure} +\end{centering} +\end{figure} + \end{document} +