示例#1
0
def main():
    parser = OptionParser(__doc__.strip(), version="%prog " + __version__)
    (options, args) = parser.parse_args()

    if len(args) != 2:
        parser.print_help()
        sys.exit(1)

    longitude = float(args[0])
    latitude = float(args[1])

    flinn_engdahl = FlinnEngdahl()
    print flinn_engdahl.get_region(longitude, latitude)
示例#2
0
def main():
    parser = OptionParser(__doc__.strip(), version="%prog " + __version__)
    (_options, args) = parser.parse_args()

    if len(args) != 2:
        parser.print_help()
        sys.exit(1)

    longitude = float(args[0])
    latitude = float(args[1])

    flinn_engdahl = FlinnEngdahl()
    print flinn_engdahl.get_region(longitude, latitude)
示例#3
0
class UtilFlinnEngdahlTestCase(unittest.TestCase):
    def setUp(self):
        self.flinnengdahl = FlinnEngdahl()
        self.samples_file = os.path.join(
            os.path.dirname(__file__),
            'data',
            'flinnengdahl.csv'
        )

    def test_coordinates(self):
        with open(self.samples_file, 'r') as fh:
            for line in fh:
                longitude, latitude, checked_region = line.strip().split('\t')
                longitude = float(longitude)
                latitude = float(latitude)

                region = self.flinnengdahl.get_region(longitude, latitude)
                self.assertEqual(
                    region,
                    checked_region,
                    msg="%f, %f got %s instead of %s" % (
                        longitude,
                        latitude,
                        region,
                        checked_region
                    )
                )
示例#4
0
class UtilFlinnEngdahlTestCase(unittest.TestCase):
    def setUp(self):
        self.flinnengdahl = FlinnEngdahl()
        self.samples_file = os.path.join(
            os.path.dirname(__file__),
            'data',
            'flinnengdahl.csv'
        )

    def test_coordinates(self):
        with open(self.samples_file, 'r') as fh:
            for line in fh:
                longitude, latitude, checked_region = line.strip().split('\t')
                longitude = float(longitude)
                latitude = float(latitude)

                region = self.flinnengdahl.get_region(longitude, latitude)
                self.assertEqual(
                    region,
                    checked_region,
                    msg="%f, %f got %s instead of %s" % (
                        longitude,
                        latitude,
                        region,
                        checked_region
                    )
                )
示例#5
0
def main(argv=None):
    parser = ArgumentParser(prog='obspy-flinn-engdahl',
                            description=__doc__.strip())
    parser.add_argument('-V', '--version', action='version',
                        version='%(prog)s ' + __version__)
    parser.add_argument('longitude', type=float,
                        help='Longitude (in degrees) of point. Positive for '
                             'East, negative for West.')
    parser.add_argument('latitude', type=float,
                        help='Latitude (in degrees) of point. Positive for '
                             'North, negative for South.')
    args = parser.parse_args(argv)

    flinn_engdahl = FlinnEngdahl()
    print(flinn_engdahl.get_region(args.longitude, args.latitude))
示例#6
0
class UtilFlinnEngdahlTestCase(unittest.TestCase):
    def setUp(self):
        self.flinnengdahl = FlinnEngdahl()
        self.samples_file = os.path.join(
            os.path.dirname(__file__),
            'data',
            'flinnengdahl.csv'
        )

    def test_coordinates(self):
        with open(self.samples_file, 'r') as fh:
            for line in fh:
                longitude, latitude, checked_region = line.strip().split('\t')
                longitude = float(longitude)
                latitude = float(latitude)

                region = self.flinnengdahl.get_region(longitude, latitude)
                self.assertEqual(
                    region,
                    checked_region,
                    msg="(%f, %f) got %s instead of %s" % (
                        longitude,
                        latitude,
                        region,
                        checked_region
                    )
                )

    def test_script(self):
        with open(self.samples_file, 'r') as fh:
            # Testing once is sufficient.
            line = fh.readline()
            longitude, latitude, checked_region = line.strip().split('\t')

            with CatchOutput() as out:
                obspy_flinnengdahl([longitude, latitude])
            region = out.stdout.strip()

            self.assertEqual(
                region,
                checked_region.encode('utf-8'),
                msg='(%s, %s) got %s instead of %s' % (
                    longitude,
                    latitude,
                    region,
                    checked_region
                )
            )