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

#835 - Improvements to trending.plot_wfs_obs_delta & wfe_histogram_pl… #836

Merged

Conversation

kulpster85
Copy link
Collaborator

#835 - Improvements to trending.plot_wfs_obs_delta & wfe_histogram_plot to support full filename paths

…e_histogram_plot to support full filename paths
@pep8speaks
Copy link

pep8speaks commented May 3, 2024

Hello @kulpster85, Thank you for updating !

Line 20:1: E302 expected 2 blank lines, found 1
Line 30:1: E302 expected 2 blank lines, found 1
Line 33:88: E261 at least two spaces before inline comment
Line 36:33: E128 continuation line under-indented for visual indent
Line 87:15: E265 block comment should start with '# '
Line 89:15: E265 block comment should start with '# '
Line 90:15: E265 block comment should start with '# '
Line 96:15: E265 block comment should start with '# '
Line 105:56: E261 at least two spaces before inline comment
Line 131:25: E226 missing whitespace around arithmetic operator
Line 133:25: E226 missing whitespace around arithmetic operator
Line 138:47: E226 missing whitespace around arithmetic operator
Line 159:13: E265 block comment should start with '# '
Line 192:1: E303 too many blank lines (3)
Line 193:25: E127 continuation line over-indented for visual indent
Line 223:5: E303 too many blank lines (2)
Line 239:10: E225 missing whitespace around operator
Line 253:25: E712 comparison to False should be 'if cond is False:' or 'if not cond:'
Line 255:27: E712 comparison to True should be 'if cond is True:' or 'if cond:'
Line 262:73: E226 missing whitespace around arithmetic operator
Line 265:64: E231 missing whitespace after ','
Line 283:10: E221 multiple spaces before operator
Line 284:41: E231 missing whitespace after ','
Line 284:71: E251 unexpected spaces around keyword / parameter equals
Line 284:73: E251 unexpected spaces around keyword / parameter equals
Line 284:83: E231 missing whitespace after ':'
Line 286:12: E261 at least two spaces before inline comment
Line 286:13: E262 inline comment should start with '# '
Line 288:57: E226 missing whitespace around arithmetic operator
Line 293:24: E225 missing whitespace around operator
Line 302:26: E225 missing whitespace around operator
Line 303:34: E226 missing whitespace around arithmetic operator
Line 303:47: E225 missing whitespace around operator
Line 304:81: E226 missing whitespace around arithmetic operator
Line 306:26: E225 missing whitespace around operator
Line 307:17: E222 multiple spaces after operator
Line 307:36: E226 missing whitespace around arithmetic operator
Line 309:50: E226 missing whitespace around arithmetic operator
Line 311:23: E221 multiple spaces before operator
Line 313:18: E222 multiple spaces after operator
Line 313:24: E226 missing whitespace around arithmetic operator
Line 322:31: E226 missing whitespace around arithmetic operator
Line 322:35: E226 missing whitespace around arithmetic operator
Line 323:33: E226 missing whitespace around arithmetic operator
Line 327:31: E226 missing whitespace around arithmetic operator
Line 327:60: E226 missing whitespace around arithmetic operator
Line 330:11: E221 multiple spaces before operator
Line 336:22: E128 continuation line under-indented for visual indent
Line 341:60: E251 unexpected spaces around keyword / parameter equals
Line 341:62: E251 unexpected spaces around keyword / parameter equals
Line 343:10: E225 missing whitespace around operator
Line 345:23: E201 whitespace after '('
Line 345:43: E226 missing whitespace around arithmetic operator
Line 346:23: E201 whitespace after '('
Line 346:43: E226 missing whitespace around arithmetic operator
Line 349:22: E128 continuation line under-indented for visual indent
Line 351:44: E226 missing whitespace around arithmetic operator
Line 357:31: E226 missing whitespace around arithmetic operator
Line 357:111: E703 statement ends with a semicolon
Line 362:30: E226 missing whitespace around arithmetic operator
Line 367:24: E231 missing whitespace after ','
Line 373:37: E226 missing whitespace around arithmetic operator
Line 373:57: E226 missing whitespace around arithmetic operator
Line 374:30: E226 missing whitespace around arithmetic operator
Line 374:35: E226 missing whitespace around arithmetic operator
Line 374:41: E226 missing whitespace around arithmetic operator
Line 374:53: E226 missing whitespace around arithmetic operator
Line 375:22: E128 continuation line under-indented for visual indent
Line 376:21: E128 continuation line under-indented for visual indent
Line 379:5: E303 too many blank lines (2)
Line 383:50: E226 missing whitespace around arithmetic operator
Line 384:17: E225 missing whitespace around operator
Line 392:1: E266 too many leading '#' for block comment
Line 394:1: E302 expected 2 blank lines, found 1
Line 418:35: E226 missing whitespace around arithmetic operator
Line 430:35: E226 missing whitespace around arithmetic operator
Line 431:20: E128 continuation line under-indented for visual indent
Line 432:20: E128 continuation line under-indented for visual indent
Line 433:20: E128 continuation line under-indented for visual indent
Line 436:5: E303 too many blank lines (2)
Line 517:67: E225 missing whitespace around operator
Line 523:5: E303 too many blank lines (2)
Line 539:75: E231 missing whitespace after ':'
Line 539:81: E226 missing whitespace around arithmetic operator
Line 540:44: E225 missing whitespace around operator
Line 580:5: E303 too many blank lines (2)
Line 586:30: E225 missing whitespace around operator
Line 591:5: E266 too many leading '#' for block comment
Line 591:5: E303 too many blank lines (2)
Line 605:5: E266 too many leading '#' for block comment
Line 605:5: E303 too many blank lines (2)
Line 606:13: E225 missing whitespace around operator
Line 610:81: E226 missing whitespace around arithmetic operator
Line 615:102: E226 missing whitespace around arithmetic operator
Line 641:5: E266 too many leading '#' for block comment
Line 647:92: E226 missing whitespace around arithmetic operator
Line 652:91: E226 missing whitespace around arithmetic operator
Line 657:74: E226 missing whitespace around arithmetic operator
Line 662:70: E226 missing whitespace around arithmetic operator
Line 664:5: E266 too many leading '#' for block comment
Line 669:75: E226 missing whitespace around arithmetic operator
Line 674:66: E226 missing whitespace around arithmetic operator
Line 682:60: E225 missing whitespace around operator
Line 685:93: E226 missing whitespace around arithmetic operator
Line 690:5: E303 too many blank lines (2)
Line 692:78: E226 missing whitespace around arithmetic operator
Line 697:70: E226 missing whitespace around arithmetic operator
Line 745:5: E303 too many blank lines (2)
Line 766:1: E305 expected 2 blank lines after class or function definition, found 1
Line 821:19: E701 multiple statements on one line (colon)
Line 824:5: E303 too many blank lines (2)
Line 824:74: W504 line break after binary operator
Line 831:5: E266 too many leading '#' for block comment
Line 875:48: E226 missing whitespace around arithmetic operator
Line 915:49: W605 invalid escape sequence '\D'
Line 947:1: E266 too many leading '#' for block comment
Line 960:46: E241 multiple spaces after ','
Line 977:43: E203 whitespace before ':'
Line 992:1: E303 too many blank lines (3)
Line 1049:5: E303 too many blank lines (2)
Line 1052:47: E225 missing whitespace around operator
Line 1053:18: E221 multiple spaces before operator
Line 1055:70: E225 missing whitespace around operator
Line 1056:75: E202 whitespace before ']'
Line 1065:51: E261 at least two spaces before inline comment
Line 1065:51: E262 inline comment should start with '# '
Line 1066:41: E201 whitespace after '('
Line 1066:64: E202 whitespace before ')'
Line 1069:5: E722 do not use bare 'except'
Line 1090:5: E303 too many blank lines (2)
Line 1091:19: E701 multiple statements on one line (colon)
Line 1176:98: W504 line break after binary operator
Line 1201:49: E231 missing whitespace after ','
Line 1212:5: E266 too many leading '#' for block comment
Line 1224:5: E265 block comment should start with '# '
Line 1224:5: E303 too many blank lines (2)
Line 1225:5: E265 block comment should start with '# '
Line 1226:26: E201 whitespace after '('
Line 1227:30: E231 missing whitespace after ','
Line 1229:25: E226 missing whitespace around arithmetic operator
Line 1229:39: E226 missing whitespace around arithmetic operator
Line 1229:48: E226 missing whitespace around arithmetic operator
Line 1229:62: E226 missing whitespace around arithmetic operator
Line 1233:5: E266 too many leading '#' for block comment
Line 1244:60: E226 missing whitespace around arithmetic operator
Line 1244:71: E226 missing whitespace around arithmetic operator
Line 1244:88: E226 missing whitespace around arithmetic operator
Line 1244:94: E261 at least two spaces before inline comment
Line 1246:74: E226 missing whitespace around arithmetic operator
Line 1247:36: W605 invalid escape sequence '\D'
Line 1249:32: E226 missing whitespace around arithmetic operator
Line 1249:34: E226 missing whitespace around arithmetic operator
Line 1253:26: E201 whitespace after '('
Line 1261:5: E303 too many blank lines (2)
Line 1274:49: E226 missing whitespace around arithmetic operator
Line 1275:23: E225 missing whitespace around operator
Line 1275:32: E225 missing whitespace around operator
Line 1307:146: E226 missing whitespace around arithmetic operator
Line 1310:132: E226 missing whitespace around arithmetic operator
Line 1330:30: E261 at least two spaces before inline comment
Line 1332:134: E226 missing whitespace around arithmetic operator
Line 1335:132: E226 missing whitespace around arithmetic operator
Line 1343:22: E231 missing whitespace after ','
Line 1346:46: E251 unexpected spaces around keyword / parameter equals
Line 1346:48: E251 unexpected spaces around keyword / parameter equals
Line 1351:48: E226 missing whitespace around arithmetic operator
Line 1351:52: E226 missing whitespace around arithmetic operator
Line 1351:66: E226 missing whitespace around arithmetic operator
Line 1351:70: E226 missing whitespace around arithmetic operator
Line 1352:40: E128 continuation line under-indented for visual indent
Line 1382:5: E303 too many blank lines (2)
Line 1394:50: E226 missing whitespace around arithmetic operator
Line 1394:54: E226 missing whitespace around arithmetic operator
Line 1394:82: E226 missing whitespace around arithmetic operator
Line 1397:69: E226 missing whitespace around arithmetic operator
Line 1398:67: E231 missing whitespace after ','
Line 1400:69: E226 missing whitespace around arithmetic operator
Line 1401:67: E231 missing whitespace after ','
Line 1405:5: E303 too many blank lines (3)
Line 1406:41: E231 missing whitespace after ','
Line 1406:83: E231 missing whitespace after ':'
Line 1406:97: E231 missing whitespace after ':'
Line 1406:112: E231 missing whitespace after ':'
Line 1407:85: E231 missing whitespace after ':'
Line 1407:97: E231 missing whitespace after ':'
Line 1410:5: E303 too many blank lines (2)
Line 1410:11: E231 missing whitespace after ','
Line 1411:11: E231 missing whitespace after ','
Line 1413:11: E231 missing whitespace after ','
Line 1413:29: E226 missing whitespace around arithmetic operator
Line 1414:11: E231 missing whitespace after ','
Line 1414:29: E226 missing whitespace around arithmetic operator
Line 1416:11: E231 missing whitespace after ','
Line 1416:28: E226 missing whitespace around arithmetic operator
Line 1416:36: E226 missing whitespace around arithmetic operator
Line 1417:11: E231 missing whitespace after ','
Line 1417:28: E226 missing whitespace around arithmetic operator
Line 1417:36: E226 missing whitespace around arithmetic operator
Line 1420:5: E303 too many blank lines (2)
Line 1421:41: E226 missing whitespace around arithmetic operator
Line 1421:48: E226 missing whitespace around arithmetic operator
Line 1422:41: E226 missing whitespace around arithmetic operator
Line 1422:48: E226 missing whitespace around arithmetic operator
Line 1423:11: E231 missing whitespace after ','
Line 1423:22: E231 missing whitespace after ','
Line 1424:11: E231 missing whitespace after ','
Line 1424:22: E231 missing whitespace after ','
Line 1427:5: E303 too many blank lines (2)
Line 1427:11: E231 missing whitespace after ','
Line 1428:11: E231 missing whitespace after ','
Line 1429:11: E231 missing whitespace after ','
Line 1430:11: E231 missing whitespace after ','
Line 1431:11: E231 missing whitespace after ','
Line 1436:5: E303 too many blank lines (2)
Line 1437:26: E251 unexpected spaces around keyword / parameter equals
Line 1437:28: E251 unexpected spaces around keyword / parameter equals
Line 1437:35: E231 missing whitespace after ','
Line 1437:94: E202 whitespace before ')'
Line 1486:5: E303 too many blank lines (2)
Line 1491:51: E226 missing whitespace around arithmetic operator
Line 1491:55: E226 missing whitespace around arithmetic operator
Line 1491:84: E225 missing whitespace around operator
Line 1494:71: E226 missing whitespace around arithmetic operator
Line 1495:69: E231 missing whitespace after ','
Line 1497:71: E226 missing whitespace around arithmetic operator
Line 1498:69: E231 missing whitespace after ','
Line 1501:5: E303 too many blank lines (2)
Line 1502:41: E231 missing whitespace after ','
Line 1502:83: E231 missing whitespace after ':'
Line 1502:96: E231 missing whitespace after ':'
Line 1502:110: E231 missing whitespace after ':'
Line 1503:76: E128 continuation line under-indented for visual indent
Line 1503:84: E231 missing whitespace after ':'
Line 1503:96: E231 missing whitespace after ':'
Line 1506:5: E303 too many blank lines (2)
Line 1506:11: E231 missing whitespace after ','
Line 1507:11: E231 missing whitespace after ','
Line 1509:11: E231 missing whitespace after ','
Line 1509:29: E226 missing whitespace around arithmetic operator
Line 1510:11: E231 missing whitespace after ','
Line 1510:29: E226 missing whitespace around arithmetic operator
Line 1512:11: E231 missing whitespace after ','
Line 1512:29: E226 missing whitespace around arithmetic operator
Line 1512:38: E226 missing whitespace around arithmetic operator
Line 1513:11: E231 missing whitespace after ','
Line 1513:29: E226 missing whitespace around arithmetic operator
Line 1513:38: E226 missing whitespace around arithmetic operator
Line 1516:42: E226 missing whitespace around arithmetic operator
Line 1516:51: E226 missing whitespace around arithmetic operator
Line 1517:42: E226 missing whitespace around arithmetic operator
Line 1517:51: E226 missing whitespace around arithmetic operator
Line 1518:11: E231 missing whitespace after ','
Line 1518:21: E231 missing whitespace after ','
Line 1519:11: E231 missing whitespace after ','
Line 1519:21: E231 missing whitespace after ','
Line 1523:5: E303 too many blank lines (3)
Line 1523:11: E231 missing whitespace after ','
Line 1524:11: E231 missing whitespace after ','
Line 1525:11: E231 missing whitespace after ','
Line 1526:11: E231 missing whitespace after ','
Line 1527:11: E231 missing whitespace after ','
Line 1532:5: E303 too many blank lines (2)
Line 1533:26: E251 unexpected spaces around keyword / parameter equals
Line 1533:28: E251 unexpected spaces around keyword / parameter equals
Line 1533:35: E231 missing whitespace after ','
Line 1533:94: E202 whitespace before ')'
Line 1536:5: E303 too many blank lines (2)
Line 1558:5: E731 do not assign a lambda expression, use a def
Line 1561:19: E701 multiple statements on one line (colon)
Line 1565:16: E225 missing whitespace around operator
Line 1587:33: E231 missing whitespace after ','
Line 1589:85: E231 missing whitespace after ','
Line 1597:5: E303 too many blank lines (2)
Line 1599:18: E128 continuation line under-indented for visual indent
Line 1599:20: E231 missing whitespace after ','
Line 1599:22: E231 missing whitespace after ','
Line 1612:35: E231 missing whitespace after ','
Line 1615:15: E201 whitespace after '('
Line 1615:35: E226 missing whitespace around arithmetic operator
Line 1615:44: E226 missing whitespace around arithmetic operator
Line 1615:64: E226 missing whitespace around arithmetic operator
Line 1616:15: E128 continuation line under-indented for visual indent
Line 1617:14: E128 continuation line under-indented for visual indent
Line 1618:15: E201 whitespace after '('
Line 1618:24: E226 missing whitespace around arithmetic operator
Line 1618:43: E226 missing whitespace around arithmetic operator
Line 1618:52: E226 missing whitespace around arithmetic operator
Line 1619:15: E128 continuation line under-indented for visual indent
Line 1620:14: E128 continuation line under-indented for visual indent
Line 1625:20: E128 continuation line under-indented for visual indent
Line 1629:35: E226 missing whitespace around arithmetic operator
Line 1630:39: E226 missing whitespace around arithmetic operator
Line 1630:48: E226 missing whitespace around arithmetic operator
Line 1631:28: E226 missing whitespace around arithmetic operator
Line 1631:48: E226 missing whitespace around arithmetic operator
Line 1636:14: E128 continuation line under-indented for visual indent
Line 1639:5: E303 too many blank lines (2)
Line 1642:19: E225 missing whitespace around operator
Line 1645:9: E225 missing whitespace around operator
Line 1646:47: E226 missing whitespace around arithmetic operator
Line 1646:55: E226 missing whitespace around arithmetic operator
Line 1648:49: E226 missing whitespace around arithmetic operator
Line 1648:57: E226 missing whitespace around arithmetic operator
Line 1650:46: E226 missing whitespace around arithmetic operator
Line 1650:54: E226 missing whitespace around arithmetic operator
Line 1653:47: E226 missing whitespace around arithmetic operator
Line 1653:59: E226 missing whitespace around arithmetic operator
Line 1653:67: E226 missing whitespace around arithmetic operator
Line 1657:55: E251 unexpected spaces around keyword / parameter equals
Line 1657:57: E251 unexpected spaces around keyword / parameter equals
Line 1699:5: E303 too many blank lines (2)
Line 1702:57: E226 missing whitespace around arithmetic operator
Line 1702:64: E226 missing whitespace around arithmetic operator
Line 1708:19: E222 multiple spaces after operator
Line 1730:53: E226 missing whitespace around arithmetic operator
Line 1737:31: E225 missing whitespace around operator
Line 1743:5: E303 too many blank lines (2)
Line 1748:32: E226 missing whitespace around arithmetic operator
Line 1759:33: E225 missing whitespace around operator
Line 1760:51: E226 missing whitespace around arithmetic operator
Line 1764:42: E231 missing whitespace after ','
Line 1768:56: E231 missing whitespace after ','
Line 1773:28: E226 missing whitespace around arithmetic operator
Line 1773:87: E203 whitespace before ','
Line 1776:28: E231 missing whitespace after ','
Line 1777:25: E128 continuation line under-indented for visual indent
Line 1778:55: E226 missing whitespace around arithmetic operator
Line 1780:18: E231 missing whitespace after ','
Line 1824:25: W605 invalid escape sequence '\D'
Line 1832:1: E266 too many leading '#' for block comment
Line 1847:52: E251 unexpected spaces around keyword / parameter equals
Line 1847:54: E251 unexpected spaces around keyword / parameter equals
Line 1847:59: E226 missing whitespace around arithmetic operator
Line 1847:77: E261 at least two spaces before inline comment
Line 1847:78: E262 inline comment should start with '# '
Line 1848:47: E226 missing whitespace around arithmetic operator
Line 1873:41: E231 missing whitespace after ','
Line 1905:43: E226 missing whitespace around arithmetic operator
Line 1909:9: E266 too many leading '#' for block comment
Line 1936:13: E266 too many leading '#' for block comment
Line 1942:64: E226 missing whitespace around arithmetic operator
Line 1944:22: E128 continuation line under-indented for visual indent
Line 1945:22: E128 continuation line under-indented for visual indent
Line 1946:22: E128 continuation line under-indented for visual indent
Line 1956:9: E266 too many leading '#' for block comment
Line 1960:82: E226 missing whitespace around arithmetic operator
Line 1968:22: E225 missing whitespace around operator
Line 1976:19: E126 continuation line over-indented for hanging indent
Line 1977:27: E251 unexpected spaces around keyword / parameter equals
Line 1977:29: E251 unexpected spaces around keyword / parameter equals
Line 1977:82: E225 missing whitespace around operator
Line 1981:21: E128 continuation line under-indented for visual indent
Line 1986:5: E303 too many blank lines (2)

Comment last updated at 2024-05-03 21:40:26 UTC

Copy link
Collaborator

@mperrin mperrin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couple minor points. One a comment, the other a question.

@@ -1462,17 +1464,18 @@ def plot_wfs_obs_delta(fn1, fn2, vmax_fraction=1.0):
"""
from skimage.registration import phase_cross_correlation

_ = webbpsf.mast_wss.mast_retrieve_opd(fn1)
_ = webbpsf.mast_wss.mast_retrieve_opd(fn2)
if download_opds == True:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor: the == True here is unnecessary.


opd, hdul1 = webbpsf.trending._read_opd(fn1)
opd, hdul1 = webbpsf.trending._read_opd(fn1, auto_download=download_opds)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't quite follow the logic of the change here. If download_opds is True, then the previous lines will have just downloaded those files, in which case there is no need to pass auto_download=True to the _read_opd function, because the files are already downloaded? Am I misunderstanding?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So the reason for this is because the read_opd takes a filename but this change will allow for the full file path to be provided. So I wanted to prevent the download since the full_file_path won't exist when combined with the webbpsf_data_path.

def _read_opd(filename, auto_download=True): full_file_path = os.path.join(webbpsf.utils.get_webbpsf_data_path(), 'MAST_JWST_WSS_OPDs', filename) if not os.path.exists(full_file_path) and auto_download:

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand what you're trying to do but I don't see that change in _read_opd. Is that a change you intend to add to this PR? Right now the code in _read_opd is always going to append some directories on the front of the filename, regardless of the auto_download flag. I'm looking right at that function in this PR and the existing code is as follows:

def _read_opd(filename, auto_download=True):
    """Trivial utilty function to read OPD from a WSS-output FITS file
    If the file does not exist locally, try to retrieve it from MAST automatically."""
    full_file_path = os.path.join(webbpsf.utils.get_webbpsf_data_path(), 'MAST_JWST_WSS_OPDs', filename)
    if not os.path.exists(full_file_path) and auto_download:
        webbpsf.mast_wss.mast_retrieve_opd(filename)
    opdhdu = fits.open(full_file_path)
    opd = opdhdu[1].data.copy()
    return opd, opdhdu


Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's always going to assign full_file_path and then try to open that... regardless of the download. yes?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. I removed the auto_download call in the plot_wfs_obs_delta. Turns out the os.path.join has the smarts to ignore all previous segments when joining with an absolute path segment.

 os.path.join(path, *paths)

    Join one or more path segments intelligently. The return value is the concatenation of path and all members of *paths, with exactly one directory separator following each non-empty part, except the last. That is, the result will only end in a separator if the last part is either empty or ends in a separator. If a segment is an absolute path (which on Windows requires both a drive and a root), then all previous segments are ignored and joining continues from the absolute path segment.

…e_histogram_plot to support full filename paths - remove unneccessary == True check
…e_histogram_plot to support full filename paths
Copy link
Collaborator

@mperrin mperrin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me.

@mperrin mperrin merged commit e6678bd into spacetelescope:develop May 6, 2024
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants