Skip to content

Commit

Permalink
updates to align more with DM style guide.
Browse files Browse the repository at this point in the history
  • Loading branch information
humnaawan committed Feb 13, 2025
1 parent 238cf10 commit c009685
Show file tree
Hide file tree
Showing 20 changed files with 68 additions and 67 deletions.
6 changes: 3 additions & 3 deletions rubin_sim/maf/batches/radar_limited.py
Original file line number Diff line number Diff line change
Expand Up @@ -511,7 +511,7 @@ def radar_limited(
subgroupCount = 1

displayDict["subgroup"] = f"{subgroupCount}: Static Science"
## Static Science
# Static Science
# Calculate the static science metrics - effective survey area,
# mean/median coadded depth, stdev of
# coadded depth and the 3x2ptFoM emulator.
Expand Down Expand Up @@ -565,7 +565,7 @@ def radar_limited(
displayDict["order"] += 1
bundleList.append(bundle)

## LSS Science
# LSS Science
# The only metric we have from LSS is the NGals metric -
# which is similar to the GalaxyCountsExtended
# metric, but evaluated only on the depth/dust cuts footprint.
Expand All @@ -574,7 +574,7 @@ def radar_limited(
displayDict["order"] = 0
plotDict = {"n_ticks": 5}

## WL metrics
# WL metrics
# Calculates the number of visits per pointing, after removing
# parts of the footprint due to dust/depth
# Count visits in gri bands.
Expand Down
8 changes: 4 additions & 4 deletions rubin_sim/maf/batches/science_radar_batch.py
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,7 @@ def science_radar_batch(
subgroupCount = 1

displayDict["subgroup"] = f"{subgroupCount}: Static Science"
## Static Science
# Static Science
# Calculate the static science metrics - effective survey area,
# mean/median coadded depth, stdev of coadded depth and
# the 3x2ptFoM emulator.
Expand Down Expand Up @@ -602,7 +602,7 @@ def science_radar_batch(
displayDict["order"] += 1
bundleList.append(bundle)

## LSS Science
# LSS Science
# The only metric we have from LSS is the NGals metric -
# which is similar to the GalaxyCountsExtended
# metric, but evaluated only on the depth/dust cuts footprint.
Expand Down Expand Up @@ -645,7 +645,7 @@ def science_radar_batch(
)
bundleList.append(bundle)

## WL metrics
# WL metrics
# Calculates the number of visits per pointing,
# after removing parts of the footprint due to dust/depth.
# Count visits in gri bands.
Expand Down Expand Up @@ -1815,7 +1815,7 @@ def science_radar_batch(
)
)

## Local Volume Dwarf Satellites
# Local Volume Dwarf Satellites
displayDict["group"] = "Local Volume"
displayDict["subgroup"] = "LV dwarf satellites"
displayDict["order"] = 0
Expand Down
11 changes: 6 additions & 5 deletions rubin_sim/maf/ddf_dir.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
__all__ = ("ddf_dir",)

import matplotlib

matplotlib.use("Agg")
import argparse
import glob
import os
Expand All @@ -12,6 +7,12 @@
import rubin_sim.maf.db as db
import rubin_sim.maf.metric_bundles as mb

__all__ = ("ddf_dir",)

import matplotlib

matplotlib.use("Agg")


def ddf_dir():
"""
Expand Down
11 changes: 6 additions & 5 deletions rubin_sim/maf/glance_dir.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
__all__ = ("glance_dir",)

import matplotlib

matplotlib.use("Agg")
import argparse
import glob
import os
Expand All @@ -12,6 +7,12 @@
import rubin_sim.maf.db as db
import rubin_sim.maf.metric_bundles as mb

__all__ = ("glance_dir",)

import matplotlib

matplotlib.use("Agg")


def glance_dir():
"""
Expand Down
2 changes: 1 addition & 1 deletion rubin_sim/maf/maf_contrib/tdes_pop_metric.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def interp(self, t, filtername, lc_indx=0):
filtername : str
The filter. one of ugrizy
lc_index : int (0)
  Which file to use.
Which file to use.
"""

result = np.interp(
Expand Down
2 changes: 1 addition & 1 deletion rubin_sim/maf/maf_contrib/transient_ascii_sed_metric.py
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ def evaluate_all_detection_criteria(self, data_slice):

# Find the unique number of light curves that passed the required
# number of conditions
self.num_detected += len(np.where(self.transient_detected == True)[0])
self.num_detected += len(np.where(self.transient_detected is True)[0])

def evaluate_pre_time_detection_criteria(self, t_id):
"""
Expand Down
14 changes: 7 additions & 7 deletions rubin_sim/maf/maf_night_report.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
from . import db as db
from . import metricBundles as metricBundles
from . import metrics as metrics
from . import plots as plots
from . import slicers as slicers
from .batches import col_map_dict

__all__ = ("make_bundle_list", "maf_night_report")

import argparse
Expand All @@ -6,13 +13,6 @@

# Set matplotlib backend (to create plots where DISPLAY is not set).
matplotlib.use("Agg")
from . import db as db
from . import metricBundles as metricBundles
from . import metrics as metrics
from . import plots as plots
from . import slicers as slicers
from . import utils as utils
from .batches import col_map_dict


def make_bundle_list(
Expand Down
10 changes: 5 additions & 5 deletions rubin_sim/maf/metadata_dir.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
from . import batches as batches
from .db import ResultsDb
from .metric_bundles import MetricBundleGroup
from .slicers import HealpixSlicer, make_wfd_subset_slicer

__all__ = ("metadata_dir",)

import argparse
Expand All @@ -9,11 +14,6 @@

matplotlib.use("Agg")

from . import batches as batches
from .db import ResultsDb
from .metric_bundles import MetricBundleGroup
from .slicers import HealpixSlicer, make_wfd_subset_slicer


def metadata_dir():
"""
Expand Down
2 changes: 1 addition & 1 deletion rubin_sim/maf/metrics/galplane_time_sampling_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ def __init__(
self.tau_var = tau_var
else:
self.tau_var = TAU_OBS * 5
### NOTE: I would recommend dropping tau_var 10 and 25 from this
# NOTE: I would recommend dropping tau_var 10 and 25 from this
# analysis unless the metric is changed
# these intervals are so short they will *always* be dropped
# during the season gap
Expand Down
2 changes: 1 addition & 1 deletion rubin_sim/maf/metrics/sky_sat_metric.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ def __init__(self, metric_name="SkySaturation", units="#", **kwargs):
def run(self, data_slice, slice_point):
# Saturation stacker returns NaN if the sky saturates
finite = np.isfinite(data_slice["saturation_mag"])
result = np.size(np.where(finite == False)[0])
result = np.size(np.where(not finite)[0])
return result
2 changes: 1 addition & 1 deletion rubin_sim/maf/metrics/sn_n_sn_metric.py
Original file line number Diff line number Diff line change
Expand Up @@ -558,7 +558,7 @@ def duration_z(self, grp, min_duration=60.0):
`pd.DataFrame` with season_length, z, T0_min and T0_max cols
"""
## IS THIS CALLED FROM ANYWHERE?
# IS THIS CALLED FROM ANYWHERE?
daymin = grp["MJD_min"].values
daymax = grp["MJD_max"].values
dur_z = pd.DataFrame(self.zrange, columns=["z"])
Expand Down
8 changes: 4 additions & 4 deletions rubin_sim/maf/metrics/technical_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def __init__(self, col="filter", order_by="observationStartMJD", **kwargs):
def run(self, data_slice, slice_point=None):
idxs = np.argsort(data_slice[self.order_by])
diff = data_slice[self.col][idxs][1:] != data_slice[self.col][idxs][:-1]
return np.size(np.where(diff == True)[0])
return np.size(np.where(diff is True)[0])


class MinTimeBetweenStatesMetric(BaseMetric):
Expand Down Expand Up @@ -60,7 +60,7 @@ def run(self, data_slice, slice_point=None):
# Sort on time, to be sure we've got changes in the right order.
idxs = np.argsort(data_slice[self.time_col])
changes = data_slice[self.change_col][idxs][1:] != data_slice[self.change_col][idxs][:-1]
condition = np.where(changes == True)[0]
condition = np.where(changes is True)[0]
changetimes = data_slice[self.time_col][idxs][1:][condition]
prevchangetime = np.concatenate(
(
Expand Down Expand Up @@ -115,7 +115,7 @@ def run(self, data_slice, slice_point=None):
# Sort on time, to be sure we've got changes in the right order.
idxs = np.argsort(data_slice[self.time_col])
changes = data_slice[self.change_col][idxs][1:] != data_slice[self.change_col][idxs][:-1]
condition = np.where(changes == True)[0]
condition = np.where(changes is True)[0]
changetimes = data_slice[self.time_col][idxs][1:][condition]
prevchangetime = np.concatenate(
(
Expand Down Expand Up @@ -172,7 +172,7 @@ def run(self, data_slice, slice_point=None):
# Sort on time, to be sure we've got changes in the right order.
idxs = np.argsort(data_slice[self.time_col])
changes = data_slice[self.change_col][idxs][:-1] != data_slice[self.change_col][idxs][1:]
condition = np.where(changes == True)[0]
condition = np.where(changes is True)[0]
changetimes = data_slice[self.time_col][idxs][1:][condition]
# If there are 0 filter changes ...
if changetimes.size == 0:
Expand Down
4 changes: 2 additions & 2 deletions rubin_sim/maf/run_moving_join.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from . import batches as batches

__all__ = ("run_moving_join",)

import argparse
Expand All @@ -9,8 +11,6 @@

matplotlib.use("Agg")

from . import batches as batches


def run_moving_join():
"""Join split metric outputs into a single metric output file."""
Expand Down
14 changes: 7 additions & 7 deletions rubin_sim/maf/run_selfcal_metric.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
from .db import ResultsDb
from .maf_contrib import PhotometricSelfCalUniformityMetric
from .metric_bundles import MetricBundle, MetricBundleGroup
from .metrics import IdentityMetric
from .plots import HealpixHistogram, HealpixSkyMap, PlotHandler
from .slicers import HealpixSlicer, UniSlicer

__all__ = ("run_selfcal_metric",)

import argparse
Expand All @@ -10,13 +17,6 @@

matplotlib.use("Agg")

from .db import ResultsDb
from .maf_contrib import PhotometricSelfCalUniformityMetric
from .metric_bundles import MetricBundle, MetricBundleGroup
from .metrics import IdentityMetric
from .plots import HealpixHistogram, HealpixSkyMap, PlotHandler
from .slicers import HealpixSlicer, UniSlicer


def run_selfcal_metric():
"""
Expand Down
8 changes: 4 additions & 4 deletions rubin_sim/maf/scimaf_dir.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
from . import batches as batches
from . import db as db
from . import metricBundles as mmB

__all__ = ("scimaf_dir",)

import argparse
Expand All @@ -12,10 +16,6 @@

matplotlib.use("Agg")

from . import batches as batches
from . import db as db
from . import metricBundles as mmB


def scimaf_dir():
"""Run the science batch on all .db files in a directory."""
Expand Down
2 changes: 1 addition & 1 deletion rubin_sim/maf/web/maf_run_results.py
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,7 @@ def order_plots(self, sky_plots):
# that do NOT match original _*_ pattern.
pattern = "_[ugrizy]_"
nonmatches = np.array([bool(re.search(pattern, x)) for x in sky_plots["plot_file"]])
nonmatch_sky_plots = sky_plots[nonmatches == False]
nonmatch_sky_plots = sky_plots[nonmatches is False]
if len(nonmatch_sky_plots) > 0:
for sky_plot in nonmatch_sky_plots:
ordered_sky_plots.append(self.plot_dict(np.array([sky_plot])))
Expand Down
4 changes: 2 additions & 2 deletions rubin_sim/satellite_constellations/sat_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ def update_mjd(self, mjd):
self.azimuth_rad = np.array(self.azimuth_rad)
self.illum = np.array(self.illum)
# Keep track of the ones that are up and illuminated
self.visible = np.where((self.altitudes_rad >= self.alt_limit_rad) & (self.illum == True))[0]
self.visible = np.where((self.altitudes_rad >= self.alt_limit_rad) & (self.illum is True))[0]

def paths_array(self, mjds):
"""Calculate and return the RA/Dec/Alt and illumination status
Expand Down Expand Up @@ -409,7 +409,7 @@ def check_pointings(
# np.where confuses me when used on a 2d array.
above_illum_indx = np.where(
((sat_alt_1 > self.alt_limit_rad) | (sat_alt_2 > self.alt_limit_rad))
& ((sat_illum_1 == True) | (sat_illum_2 == True))
& ((sat_illum_1 is True) | (sat_illum_2 is True))
)

# point_to_line_distance can take arrays,
Expand Down
2 changes: 1 addition & 1 deletion rubin_sim/skybrightness/data/ESO_Spectra/eso_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from rubin_sim.data import get_data_dir
from rubin_sim.phot_utils import Bandpass, Sed

## Tools for calling and reading things from the ESO sky model.
# Tools for calling and reading things from the ESO sky model.
# Installing 'calcskymodel' is a major headache,
# let's hope we don't have to do this again anytime soon

Expand Down
6 changes: 3 additions & 3 deletions tests/maf/test_healpixslicer.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import matplotlib

matplotlib.use("Agg")
import unittest

import healpy as hp
import matplotlib
import numpy as np
import numpy.lib.recfunctions as rfn
import numpy.ma as ma

from rubin_sim.maf.slicers import HealpixSlicer

matplotlib.use("Agg")


def make_data_values(
size=100,
Expand Down
Loading

0 comments on commit c009685

Please sign in to comment.