Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v1.1 updates #24

Merged
merged 54 commits into from
Mar 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
ae0633f
small docs update
dpesce Dec 29, 2023
5890f7e
updating actions to include Python 3.11
dpesce Jan 8, 2024
14d3b13
update README
dpesce Jan 8, 2024
cc718fc
some linting of example scripts
dpesce Jan 8, 2024
c68c8f6
linting const_def
dpesce Jan 8, 2024
fad2cd7
more linting
dpesce Jan 8, 2024
938ae29
more linting
dpesce Jan 9, 2024
8afea7e
add ability to specify weather data directory
dpesce Jan 9, 2024
e910129
fix SYMBA export obs start time
dpesce Jan 18, 2024
8dd36bd
add EAVN stations
dpesce Jan 27, 2024
c290e63
add calibration functions and example
dpesce Jan 28, 2024
56e6be6
add calibration to init
dpesce Jan 29, 2024
c033743
actually add calibration files
dpesce Jan 29, 2024
847a151
update tox to install calib
dpesce Jan 29, 2024
75d419c
add calibration docs
dpesce Jan 29, 2024
ab6caba
update readme and installation for optional dependencies
dpesce Jan 29, 2024
6153197
add examples as unit tests
dpesce Jan 29, 2024
623664b
missed one test; added
dpesce Jan 29, 2024
4691e60
add some simple test coverage increases to metrics and weather
dpesce Jan 29, 2024
d997462
trying to make a coverage badge
dpesce Jan 29, 2024
a1f9c55
trying again to make coverage badge
dpesce Jan 29, 2024
ddd5a18
still trying to make coverage badge
dpesce Jan 29, 2024
dfebced
still trying to make coverage badge
dpesce Jan 29, 2024
76e9d59
still trying to make coverage badge
dpesce Jan 29, 2024
9d8bc3b
still trying to make coverage badge
dpesce Jan 29, 2024
4885ef1
still trying to make coverage badge
dpesce Jan 29, 2024
5e0cf9d
aborting code coverage badge attempt
dpesce Jan 29, 2024
36b0a9a
attempting coverage badge stuff again
dpesce Jan 29, 2024
af584a1
buglet
dpesce Jan 29, 2024
693613f
coverage badge stuff
dpesce Jan 29, 2024
01a1308
coverage badge stuff
dpesce Jan 29, 2024
c205068
coverage badge stuff
dpesce Jan 29, 2024
e290383
coverage badge stuff
dpesce Jan 29, 2024
d1d6e5a
coverage badge stuff
dpesce Jan 29, 2024
d9f7ea3
coverage badge stuff
dpesce Jan 29, 2024
b7e2ded
coverage badge stuff
dpesce Jan 29, 2024
d94494c
coverage badge stuff
dpesce Jan 29, 2024
1da4845
coverage badge stuff
dpesce Jan 29, 2024
a404b2e
coverage badge stuff
dpesce Jan 29, 2024
33c292c
coverage badge stuff
dpesce Jan 29, 2024
5e6b995
coverage badge stuff
dpesce Jan 29, 2024
b1bb01e
coverage badge stuff
dpesce Jan 29, 2024
1cab830
fix windspeed efficiency function
dpesce Feb 27, 2024
7986cb3
update citation
dpesce Feb 28, 2024
43fe3d2
update readme
dpesce Feb 28, 2024
502a9de
add VGOS station info
dpesce Mar 8, 2024
4cef603
check input settings for unrecognized keywords
dpesce Mar 9, 2024
82fd6aa
incorporate weather data through 2023
dpesce Mar 9, 2024
402e230
update SYMBA exports to reflect latest MeqSilhouette and rPICARD changes
dpesce Mar 9, 2024
253978f
buglet
dpesce Mar 9, 2024
ab7e5e6
add optional flag for nighttime-only observations
dpesce Mar 11, 2024
d4e0c91
add option to specify uptimes for each station individually
dpesce Mar 11, 2024
7f8c49d
add example script for daytime and uptime flagging
dpesce Mar 11, 2024
b846add
add unit test for daytime and uptime flagging
dpesce Mar 11, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
The diff you're trying to view is too large. We only load the first 3000 changed files.
65 changes: 65 additions & 0 deletions .github/workflows/run_code_coverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: Run unit tests

on:
push:
branches:
- main
- dev
pull_request:
branches:
- main

jobs:
build:

runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest]
python-version: ["3.11"]

steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip setuptools wheel
- name: Test with tox
run: |
pip install tox coverage
tox -e py
- name: Upload coverage data
uses: actions/upload-artifact@v3
with:
name: covdata
path: .coverage.*
- name: Download coverage data
uses: actions/download-artifact@v3
with:
name: covdata
- name: Combine
run: |
python -m coverage combine

# Report and write to summary.
python -m coverage report
python -m coverage report | sed 's/^/ /' >> $GITHUB_STEP_SUMMARY
python -m coverage json

export TOTAL=$(python -c "import json;print(json.load(open('coverage.json'))['totals']['percent_covered_display'])")
echo "total=$TOTAL" >> $GITHUB_ENV
echo "### Total coverage: ${TOTAL}%" >> $GITHUB_STEP_SUMMARY
- name: Make badge
uses: schneegans/[email protected]
with:
auth: ${{ secrets.GIST_TOKEN }}
gistID: de229c48256d967a1cb8b29dbf575602
filename: covbadge.json
label: code coverage
message: ${{ env.total }}%
minColorRange: 50
maxColorRange: 90
valColorRange: ${{ env.total }}
11 changes: 6 additions & 5 deletions .github/workflows/run_unit_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
push:
branches:
- main
- dev
pull_request:
branches:
- main
Expand All @@ -15,12 +16,12 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
python-version: ["3.8", "3.9", "3.10"]
python-version: ["3.8", "3.9", "3.10", "3.11"]

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
Expand All @@ -36,5 +37,5 @@ jobs:
continue-on-error: true
- name: Test with tox
run: |
pip install tox
tox -e py
pip install tox coverage
tox -e py
35 changes: 24 additions & 11 deletions CITATION.cff
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,37 @@ authors:
- family-names: "Blackburn"
given-names: "Lindy"
orcid: "https://orcid.org/0000-0002-9030-642X"
- family-names: "Hamilton"
given-names: "Linus"
- family-names: "Chaves"
given-names: "Ryan"
- family-names: "Doeleman"
given-names: "Sheperd S."
- family-names: "Freeman"
given-names: "Mark"
- family-names: "Issaoun"
given-names: "Sara"
orcid: "https://orcid.org/0000-0002-5297-921X"
- family-names: "Johnson"
given-names: "Michael D."
orcid: "https://orcid.org/0000-0002-4120-3029"
- family-names: "Lindahl"
given-names: "Greg"
orcid: "https://orcid.org/0000-0002-6100-4772"
- family-names: "Natarajan"
given-names: "Iniyan"
orcid: "https://orcid.org/0000-0001-8242-4373"
- family-names: "Paine"
given-names: "Scott N."
orcid: "https://orcid.org/0000-0003-4622-5857"
- family-names: "Palumbo"
given-names: "Daniel C. M."
orcid: "https://orcid.org/0000-0002-7179-3816"
- family-names: "Raymond"
given-names: "Alexander W."
orcid: "https://orcid.org/0000-0002-5779-4767"
- family-names: "Wielgus"
given-names: "Maciek"
orcid: "https://orcid.org/0000-0002-8635-4242"
title: "ngEHT simulation tools"
version: 0.1
date-released: 2021-09-20
- family-names: "Roelofs"
given-names: "Freek"
orcid: "https://orcid.org/0000-0001-5461-3687"
- family-names: "Tiede"
given-names: "Paul"
orcid: "https://orcid.org/0000-0003-3826-5648"
title: "ngehtsim"
version: 1.0.0
date-released: 2023-12-29
url: "https://github.com/Smithsonian/ngehtsim"
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

[![Documentation](https://img.shields.io/badge/docs-dev-blue.svg)](https://smithsonian.github.io/ngehtsim/)
[![Build status](https://github.com/Smithsonian/ngehtsim/actions/workflows/run_unit_tests.yml/badge.svg)](https://github.com/Smithsonian/ngehtsim/actions)
[![Python versions](https://img.shields.io/badge/python-3.8|3.9|3.10-blue.svg)](https://github.com/Smithsonian/ngehtsim)
[![Python versions](https://img.shields.io/badge/python-3.8|3.9|3.10|3.11-blue.svg)](https://github.com/Smithsonian/ngehtsim)
[![Code coverage](https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/dpesce/de229c48256d967a1cb8b29dbf575602/raw/covbadge.json)](https://github.com/Smithsonian/ngehtsim/actions)

A set of tools for generating synthetic data for the Event Horizon Telescope ([EHT](https://eventhorizontelescope.org/)), the next-generation Event Horizon Telescope ([ngEHT](https://www.ngeht.org)), and other very long baseline interferometric arrays of radio telescopes.

Expand All @@ -24,6 +25,12 @@ ngehtsim is only tested on Python 3.8 and higher, and it may break for earlier v
(.venv) $ pip install ./ngehtsim
```

There is an optional calibration functionality that requires some additional dependencies; it can be installed using:

```
(.venv) $ pip install ./ngehtsim[calib]
```

## Checking that it works

There are a number of example scripts contained in the [examples](./examples/) folder. You can check to make sure your ngehtsim installation is working by running one of these scripts, e.g.:
Expand Down
1 change: 1 addition & 0 deletions docs/source/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ Individual package documentation organized by area.
./obsgen
./metrics
./weather
./calibration

9 changes: 9 additions & 0 deletions docs/source/calibration.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
.. module:: calibration

Calibration utilities
=========================

Definition of the calibration interface.

.. automodule:: calibration.calibration
:members:
14 changes: 13 additions & 1 deletion docs/source/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ To install ngehtsim, run pip from the main directory:

$ pip install [--upgrade] . [--user]

If you would like to additionally install the calibration dependencies, run:

.. code-block:: console

$ pip install [--upgrade] .[calib] [--user]

Dependencies
------------------------

Expand All @@ -26,7 +32,13 @@ ngehtsim uses the following packages:
* `matplotlib <https://matplotlib.org>`_
* `scipy <https://www.scipy.org>`_
* `astropy <https://www.astropy.org/>`_
* `ngEHTforecast <https://aeb.github.io/ngEHTforecast/html/docs/src/index.html>`_

ngehtsim also has the option to include additional calibration capabilities during installation, which further requires:

* `pandas <https://pandas.pydata.org/>`_
* `eat <https://github.com/sao-eht/eat.git>`_

Generating a local version of the documation for ngehtsim requires:
Dependencies are specified in setup.py and will be handled via the pip install process. Generating a local version of the documentation for ngehtsim requires:

* `Sphinx <https://www.sphinx-doc.org>`_
Binary file added examples/data_files/M87_230GHz.fits
Binary file not shown.
Binary file removed examples/data_files/M87_230GHz_Chael.fits
Binary file not shown.
Binary file added examples/data_files/M87_345GHz.fits
Binary file not shown.
Binary file removed examples/data_files/M87_345GHz_Chael.fits
Binary file not shown.
Binary file added examples/data_files/M87_86GHz.fits
Binary file not shown.
Binary file removed examples/data_files/M87_86GHz_Chael.fits
Binary file not shown.
8 changes: 4 additions & 4 deletions examples/example_SYMBA_export/generate_observation.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@

# generate a symmetric Gaussian model object
mod = eh.model.Model()
mod = mod.add_circ_gauss(F0=1.0,FWHM=40.0*eh.RADPERUAS)
mod = mod.add_circ_gauss(F0=1.0, FWHM=40.0*eh.RADPERUAS)

# save an image of the model
im = mod.make_image(500.0*eh.RADPERUAS,512)
im = mod.make_image(500.0*eh.RADPERUAS, 512)
imfilename = '000000-I-model.fits'
im.save_fits(imfilename)

Expand All @@ -34,14 +34,14 @@
obsgen = og.obs_generator(settings)

# generate and save the observation
obs = obsgen.make_obs(im,addnoise=addnoise,addgains=addgains)
obs = obsgen.make_obs(im, addnoise=addnoise, addgains=addgains)
obs.save_uvfits('example_dataset.uvfits')

# export SYMBA-compatible input files
master_input_args = {'rpicard_path': rpicard_path,
'meqsilhouette_path': meqsilhouette_path,
'add_thermal_noise': str(addnoise)}
obsgen.export_SYMBA(symba_workdir=symba_workdir,master_input_args=master_input_args,use_two_letter=use_two_letter)
obsgen.export_SYMBA(symba_workdir=symba_workdir, master_input_args=master_input_args, use_two_letter=use_two_letter)

# move image file to SYMBA working directory
os.system('mv ' + imfilename + ' ' + symba_workdir + '/symba_input/' + imfilename)
32 changes: 15 additions & 17 deletions examples/example_data_generation/generate_observation.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
#######################################################
# imports

import numpy as np
import ehtim as eh
import ngehtsim.obs.obs_generator as og
import ngehtsim.obs.obs_plotter as op
import ngehtsim.metrics as cm
Expand All @@ -25,37 +23,37 @@
#######################################################
# make some plots of the data

op.plot_uv(obs,filename='./example_plot_uv.png')
op.plot_amp(obs,filename='./example_plot_amp.png')
op.plot_phase(obs,filename='./example_plot_phase.png')
op.plot_snr(obs,filename='./example_plot_snr.png')
op.plot_uv(obs, filename='./example_plot_uv.png')
op.plot_amp(obs, filename='./example_plot_amp.png')
op.plot_phase(obs, filename='./example_plot_phase.png')
op.plot_snr(obs, filename='./example_plot_snr.png')

#######################################################
# compute various metrics

# compute FF metric
ff = cm.calc_ff(obs,fov=200.0)
print('FF metric value is: ',ff)
ff = cm.calc_ff(obs, fov=200.0)
print('FF metric value is: ', ff)

# compute BFF metric for each Stokes parameter
for stokes in ['I','Q','U','V']:
bff = cm.calc_bff(obs,fov=200.0,stokes=stokes)
print('Stokes ' + stokes + ' BFF metric value is: ',bff)
for stokes in ['I', 'Q', 'U', 'V']:
bff = cm.calc_bff(obs, fov=200.0, stokes=stokes)
print('Stokes ' + stokes + ' BFF metric value is: ', bff)

# compute LCG metric
lcg = cm.calc_lcg(obs)
print('LCG metric value is: ',lcg)
print('LCG metric value is: ', lcg)

# compute PSS metric
pss = cm.calc_pss(obs)
print('PSS metric value (in Jy) is: ',pss)
print('PSS metric value (in Jy) is: ', pss)

# compute angular resolution metric with different weightings
for weighting in ['natural','uniform','robust']:
ar = cm.calc_ar(obs,artype='mean',weighting=weighting)
print('Average beam size (in uas) with ' + weighting + ' weighting is: ',ar)
for weighting in ['natural', 'uniform', 'robust']:
ar = cm.calc_ar(obs, artype='mean', weighting=weighting)
print('Average beam size (in uas) with ' + weighting + ' weighting is: ', ar)

#######################################################
# plot a metric versus time for the observation

op.plot_snapshot(obs,obsgen,'FF',fov=200.0,filename='./example_plot_FF.png')
op.plot_snapshot(obs, obsgen, 'FF', fov=200.0, filename='./example_plot_FF.png')
2 changes: 1 addition & 1 deletion examples/example_data_generation/settings.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
############################################################
# input files

model_file: '../data_files/M87_230GHz_Chael.fits'
model_file: '../data_files/M87_230GHz.fits'

############################################################
# observation specs
Expand Down
Loading
Loading