diff --git a/VERSION b/VERSION index ad91aa9..0d25275 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -master-v0.4.8 \ No newline at end of file +master-v0.4.9 \ No newline at end of file diff --git a/flows/load_image.py b/flows/load_image.py index db66d8e..7ecfad3 100644 --- a/flows/load_image.py +++ b/flows/load_image.py @@ -128,9 +128,11 @@ def load_image(FILENAME): image.photfilter = { 'B Bes': 'B', 'V Bes': 'V', + 'R Bes': 'R', 'g SDSS': 'gp', 'r SDSS': 'rp', 'i SDSS': 'ip', + 'i int': 'ip', # Interference filter 'u SDSS': 'up', 'z SDSS': 'zp' }.get(hdr['FILTER'].replace('_', ' '), hdr['FILTER']) @@ -142,9 +144,11 @@ def load_image(FILENAME): if len(filters_used) == 1: image.photfilter = { 'V_Bes 530_80': 'V', + 'R_Bes 650_130': 'R', "g'_SDSS 480_145": 'gp', "r'_SDSS 618_148": 'rp', "i'_SDSS 771_171": 'ip', + 'i_int 797_157': 'ip', # Interference filter "z'_SDSS 832_LP": 'zp' }.get(filters_used[0].replace(' ', ' '), filters_used[0]) else: diff --git a/flows/ztf.py b/flows/ztf.py index 1fac6bb..09188f8 100644 --- a/flows/ztf.py +++ b/flows/ztf.py @@ -101,11 +101,11 @@ def download_ztf_photometry(targetid): # Create Astropy table, cut out the needed columns # and rename columns to something better for what we are doing: tab = Table(data=jsn) - tab = tab[['fid', 'mjd', 'magpsf_corr', 'sigmapsf_corr']] + tab = tab[['fid', 'mjd', 'magpsf', 'sigmapsf']] tab.rename_column('fid', 'photfilter') tab.rename_column('mjd', 'time') - tab.rename_column('magpsf_corr', 'mag') - tab.rename_column('sigmapsf_corr', 'mag_err') + tab.rename_column('magpsf', 'mag') + tab.rename_column('sigmapsf', 'mag_err') # Remove bad values of time and magnitude: tab['time'] = np.asarray(tab['time'], dtype='float64') diff --git a/requirements.txt b/requirements.txt index db9c492..ae03ff1 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,6 @@ pytest flake8 +flake8-tabs !=2.3.0,!=2.3.1 flake8-builtins flake8-logging-format numpy >= 1.16 diff --git a/run_download_ztf.py b/run_download_ztf.py index facfac3..fe9bdda 100644 --- a/run_download_ztf.py +++ b/run_download_ztf.py @@ -48,7 +48,7 @@ def main(): # Check that output directory exists: if not os.path.isdir(output_dir): - parser.error("Output directory does not exist: '%s'" % output_dir) # noqa: G002 + parser.error(f"Output directory does not exist: '{output_dir}'") # noqa: G004 # Use API to get list of targets to process: if args.target is None: @@ -56,6 +56,10 @@ def main(): else: targets = [api.get_target(args.target)] + # Colors used for the different filters in plots: + # I know purple is in the wrong end of the scale, but not much I can do + colors = {'gp': 'tab:green', 'rp': 'tab:red', 'ip': 'tab:purple'} + # Loop through targets: for tgt in targets: logger.debug("Target: %s", tgt) @@ -67,12 +71,12 @@ def main(): # Download ZTF photometry as Astropy Table: tab = ztf.download_ztf_photometry(tgt['targetid']) logger.debug("ZTF Photometry:\n%s", tab) - if tab is None: + if tab is None or len(tab) == 0: continue # Write table to file: target_name = tab.meta['target_name'] - tab.write(os.path.join(output_dir, '{0:s}-ztf.ecsv'.format(target_name)), + tab.write(os.path.join(output_dir, f'{target_name:s}-ztf.ecsv'), format='ascii.ecsv', delimiter=',') # Find time of maxmimum and 14 days from that: @@ -85,16 +89,17 @@ def main(): ax.axvline(maximum_mjd, ls='--', c='k', lw=0.5, label='Maximum') ax.axvline(fortnight_mjd, ls='--', c='0.5', lw=0.5, label='+14 days') for fid in np.unique(tab['photfilter']): + col = colors[fid] band = tab[tab['photfilter'] == fid] ax.errorbar(band['time'], band['mag'], band['mag_err'], - ls='-', lw=0.5, marker='.', label=fid) + color=col, ls='-', lw=0.5, marker='.', label=fid) ax.invert_yaxis() ax.set_title(target_name) ax.set_xlabel('Time (MJD)') ax.set_ylabel('Magnitude') ax.legend() - fig.savefig(os.path.join(output_dir, '{0:s}-ztf.png'.format(target_name)), format='png', bbox_inches='tight') + fig.savefig(os.path.join(output_dir, f'{target_name:s}-ztf.png'), format='png', bbox_inches='tight') plt.close(fig) #-------------------------------------------------------------------------------------------------- diff --git a/setup.cfg b/setup.cfg index cb821ca..9dbb766 100644 --- a/setup.cfg +++ b/setup.cfg @@ -2,7 +2,14 @@ exclude = .git,__pycache__,notes max-line-length = 99 -enable-extensions=G +# Enable flake8-logging-format: +enable-extensions = G + +# Configuration of flake8-tabs: +use-flake8-tabs = True +blank-lines-indent = never +indent-tabs-def = 1 +indent-style = tab ignore = E117, # over-indented (set when using tabs) @@ -18,11 +25,13 @@ ignore = E305, # expected 2 blank lines after class or function definition, found 1 E501, # line too long E701, # multiple statements on one line (colon) - W191, # indentation contains tabs W503, # Line break occurred before a binary operator + ET128, # (flake8-tabs) unexpected number of tabs and spaces at start of XXX [tool:pytest] +addopts = --strict-markers --durations=10 testpaths = tests +xfail_strict = True #[coverage:run] #branch = True