예제 #1
0
 def test_file_limit(self):
     """
     Check that we don't leave file handles unclosed.
     """
     max_files = resource.getrlimit(resource.RLIMIT_NOFILE)[1] # hard limit
     dest = BytesIO()
     for _ in range(max_files):
         with redirect_stream(sys.__stdout__, dest):
             pass
예제 #2
0
 def test_file_limit(self):
     """
     Check that we don't leave file handles unclosed.
     """
     max_files = resource.getrlimit(resource.RLIMIT_NOFILE)[1]  # hard limit
     dest = BytesIO()
     for _ in range(max_files):
         with redirect_stream(sys.__stdout__, dest):
             pass
예제 #3
0
def check_for_valid_ephemeris(measures):
    """
    Checks whether the ephemeris data in use by ``measures`` is valid.
    ``measures`` should already have a valid reference frame.
    """
    # Note that we need to catch and parse the standard error produced by
    # casacore: there doesn't seem to be any other way of figuring this out.
    casacore_stderr = BytesIO()
    with redirect_stream(sys.__stderr__, casacore_stderr):
        # We assume the ephemeris is valid if it has position of the sun.
        measures.separation(measures.direction("SUN"),
                            measures.direction("SUN"))
    if "WARN" in casacore_stderr.getvalue():
        # casacore sends a warning to stderr if the ephemeris is invalid
        return False
    else:
        return True
예제 #4
0
def check_for_valid_ephemeris(measures):
    """
    Checks whether the ephemeris data in use by ``measures`` is valid.
    ``measures`` should already have a valid reference frame.
    """
    # Note that we need to catch and parse the standard error produced by
    # casacore: there doesn't seem to be any other way of figuring this out.
    casacore_stderr = BytesIO()
    with redirect_stream(sys.__stderr__, casacore_stderr):
        # We assume the ephemeris is valid if it has position of the sun.
        measures.separation(
            measures.direction("SUN"), measures.direction("SUN")
        )
    if "WARN" in casacore_stderr.getvalue():
        # casacore sends a warning to stderr if the ephemeris is invalid
        return False
    else:
        return True