Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • wenxuan.jia/pygwinc
  • sean-leavey/pygwinc
  • sebastian.steinlechner/pygwinc
  • nicholas.demos/pygwinc
  • chris.whittle/pygwinc
  • raymond.robie/pygwinc
  • mateusz.bawaj/pygwinc
  • anchal.gupta/pygwinc
  • 40m/pygwinc
  • evan.hall/pygwinc
  • kevin.kuns/pygwinc
  • geoffrey-lovelace/pygwinc
  • brittany.kamai/pygwinc
  • daniel-brown/pygwinc
  • lee-mcculler/pygwinc
  • jameson.rollins/pygwinc
  • gwinc/pygwinc
17 results
Show changes
Commits on Source (8)
......@@ -27,7 +27,7 @@ gwinc/base:
cat <<EOF > Dockerfile
FROM igwn/base:buster
RUN apt-get update -qq
RUN apt-get -y install --no-install-recommends git python3-gitlab python3 python3-yaml python3-scipy python3-matplotlib python3-ipython python3-lalsimulation python3-pypdf2 python3-h5py
RUN apt-get -y install --no-install-recommends git python3-gitlab python3 python3-yaml python3-scipy python3-matplotlib python3-lalsimulation python3-pypdf2 python3-h5py
RUN git clone https://gitlab-ci-token:ci_token@git.ligo.org/gwinc/inspiral_range.git
EOF
- docker build -t $IMAGE_TAG .
......@@ -41,8 +41,7 @@ generate_budgets:
- mkdir -p ifo
- export PYTHONPATH=/inspiral_range
- for ifo in $(python3 -c "import gwinc; print(' '.join(gwinc.IFOS))"); do
- python3 -m gwinc $ifo -s ifo/$ifo.png
- python3 -m gwinc $ifo -s ifo/$ifo.h5
- python3 -m gwinc $ifo -s ifo/$ifo.png -s ifo/$ifo.h5
- done
- python3 -m gwinc.ifo -s ifo/all_compare.png
artifacts:
......@@ -63,6 +62,7 @@ noise_change_approval:
- if: $CI_MERGE_REQUEST_ID
image: $CI_REGISTRY_IMAGE/gwinc/base:$CI_COMMIT_REF_NAME
script:
- export PYTHONPATH=/inspiral_range
- |
cat <<EOF > check_approved.py
import sys
......@@ -77,16 +77,17 @@ noise_change_approval:
approvals = mr.approvals.get()
print(approvals.approved)
EOF
- echo $CI_MERGE_REQUEST_PROJECT_ID, $CI_MERGE_REQUEST_IID, $CI_MERGE_REQUEST_TARGET_BRANCH_NAME,
- export | grep '^CI_'
- approved=$(python3 check_approved.py $CI_MERGE_REQUEST_PROJECT_ID $CI_MERGE_REQUEST_IID )
- if [[ $approved != True ]] ; then
- echo "Approval not yet given, checking for noise changes..."
- target=origin/$CI_MERGE_REQUEST_TARGET_BRANCH_NAME
- if ! python3 -m gwinc.test --git-rev $target -r gwinc_test_report.pdf ; then
- echo "NOISE CHANGES RELATIVE TO $CI_MERGE_REQUEST_TARGET_BRANCH_NAME."
- echo "Approval required to merge this branch."
- /bin/false
- else
- echo "No noise changes detected."
- echo "No noise changes detected, merge may proceed."
- fi
- else
- echo "Merge request approved, noise change accepted."
......@@ -95,7 +96,7 @@ noise_change_approval:
when: on_failure
paths:
- gwinc_test_report.pdf
expose_as: 'noise changes relative to target branch'
expose_as: 'PDF report of noise changes relative to target branch'
# generate the html doc web pages. the "pages" job has special
# meaning, as it's "public" artifact becomes the directory served
......
......@@ -3,7 +3,6 @@ import os
import signal
import argparse
import numpy as np
from IPython.terminal.embed import InteractiveShellEmbed
import logging
logging.basicConfig(
......@@ -51,6 +50,7 @@ See documentation for inspiral_range package for details.
IFO = 'aLIGO'
FREQ = '5:3000:6000'
DATA_SAVE_FORMATS = ['.hdf5', '.h5']
parser = argparse.ArgumentParser(
prog='gwinc',
......@@ -75,23 +75,23 @@ group.add_argument(
'--interactive', '-i', action='store_true',
help="interactive plot with interactive shell")
group.add_argument(
'--save', '-s',
help="save budget traces (.hdf5/.h5) or plot (.pdf/.png/.svg) to file")
'--save', '-s', action='append',
help="save plot (.png/.pdf/.svg) or budget traces (.hdf5/.h5) to file (may be specified multiple times)")
group.add_argument(
'--yaml', '-y', action='store_true',
help="print IFO as yaml to stdout and exit")
help="print IFO as yaml to stdout and exit (budget not calculated)")
group.add_argument(
'--text', '-x', action='store_true',
help="print IFO as text table to stdout and exit")
help="print IFO as text table to stdout and exit (budget not calculated)")
group.add_argument(
'--diff', '-d', metavar='IFO',
help="show differences table between another IFO description")
help="show differences table between another IFO description and exit (budget not calculated)")
group.add_argument(
'--no-plot', '-np', action='store_false', dest='plot',
help="supress plotting")
parser.add_argument(
'IFO',
help="IFO name, description file path (.yaml, .mat, .m), budget module (.py), or HDF5 data file (.hdf5, .h5)")
help="IFO name, or path to budget module (.py), description file (.yaml/.mat/.m), or HDF5 data file (.hdf5/.h5)")
def freq_from_spec(spec):
......@@ -113,7 +113,7 @@ def main():
##########
# initial arg processing
if os.path.splitext(os.path.basename(args.IFO))[1] in ['.hdf5', '.h5']:
if os.path.splitext(os.path.basename(args.IFO))[1] in DATA_SAVE_FORMATS:
from .io import load_hdf5
Budget = None
freq, traces, attrs = load_hdf5(args.IFO)
......@@ -135,6 +135,14 @@ def main():
plot_style = getattr(Budget, 'plot_style', {})
traces = None
out_data_files = set()
out_plot_files = set()
if args.save:
for path in args.save:
if os.path.splitext(path)[1] in DATA_SAVE_FORMATS:
out_data_files.add(path)
out_plot_files = set(args.save) - out_data_files
if args.ifo:
for paramval in args.ifo:
param, val = paramval.split('=', 1)
......@@ -234,31 +242,12 @@ def main():
plot_style['title'] += '\n{}'.format(fom_title)
##########
# output
# save noise traces to HDF5 file
if args.save and os.path.splitext(args.save)[1] in ['.hdf5', '.h5']:
from .io import save_hdf5
logging.info("saving budget traces {}...".format(args.save))
if ifo:
plot_style['IFO'] = ifo.to_yaml()
save_hdf5(
path=args.save,
freq=freq,
traces=traces,
**plot_style
)
# interactive
# interactive shell plotting
elif args.interactive:
if args.interactive:
from IPython.terminal.embed import InteractiveShellEmbed
ipshell = InteractiveShellEmbed(
user_ns={
'freq': freq,
'traces': traces,
'ifo': ifo,
'plot_style': plot_style,
'plot_noise': plot_noise,
},
banner1='''
GWINC interactive plotter
......@@ -266,14 +255,39 @@ You may interact with plot using "plt." methods, e.g.:
>>> plt.title("foo")
>>> plt.savefig("foo.pdf")
''')
''',
user_ns={
'freq': freq,
'traces': traces,
'ifo': ifo,
'plot_style': plot_style,
'plot_noise': plot_noise,
},
)
ipshell.enable_pylab()
ipshell.run_code("plot_noise(freq, traces, **plot_style)")
ipshell.run_code("plt.title('{}')".format(plot_style['title']))
ipshell.ex("fig = plot_noise(freq, traces, **plot_style)")
ipshell.ex("plt.title('{}')".format(plot_style['title']))
ipshell()
##########
# output
# save noise traces to HDF5 file
if out_data_files:
from .io import save_hdf5
attrs = dict(plot_style)
attrs['IFO'] = ifo.to_yaml()
for path in out_data_files:
logging.info("saving budget traces {}...".format(path))
save_hdf5(
path=path,
freq=freq,
traces=traces,
**attrs,
)
# standard plotting
elif args.plot:
if args.plot or out_plot_files:
logging.info("plotting noises...")
fig = plt.figure()
ax = fig.add_subplot(1, 1, 1)
......@@ -284,10 +298,9 @@ You may interact with plot using "plt." methods, e.g.:
**plot_style
)
fig.tight_layout()
if args.save:
fig.savefig(
args.save,
)
if out_plot_files:
for path in out_plot_files:
fig.savefig(path)
else:
plt.show()
......
......@@ -16,17 +16,17 @@ from PyPDF2 import PdfFileReader, PdfFileWriter
from .. import IFOS, load_budget
from ..io import load_hdf5
logging.basicConfig(
format='%(message)s',
level=os.getenv('LOG_LEVEL', logging.INFO))
try:
import inspiral_range
except ImportError:
logging.warning("inspiral_range package not found, range will not be calculated")
inspiral_range = None
logging.basicConfig(
format='%(message)s',
level=os.getenv('LOG_LEVEL', logging.INFO))
TOLERANCE = 1e-6
CACHE_LIMIT = 5
......@@ -272,6 +272,9 @@ gwinc/test/cache/<SHA1>. Old caches are automatically pruned.""",
rgroup.add_argument(
'--git-rev', '-g', metavar='REV',
help="specify specific git revision to compare against")
rgroup.add_argument(
'--head', '-gh', action='store_const', dest='git_rev', const='HEAD',
help="shortcut for '--git-rev HEAD'")
ogroup = parser.add_mutually_exclusive_group()
ogroup.add_argument(
'--plot', '-p', action='store_true',
......@@ -292,7 +295,7 @@ gwinc/test/cache/<SHA1>. Old caches are automatically pruned.""",
if not remote:
sys.exit("Could not resolve upstream remote name")
git_rev = '{}/master'.format(remote)
logging.info("presumed upstream git reference: {}".format(git_rev))
logging.info("git rev: {}".format(git_rev))
git_hash = git_rev_resolve_hash(git_rev)
if not git_hash:
sys.exit("Could not resolve reference, could not run test.")
......