Skip to content

Instantly share code, notes, and snippets.

@MiCurry
Created July 24, 2019 16:00
Show Gist options
  • Save MiCurry/33632dbf29fca73ad9989454034ab91f to your computer and use it in GitHub Desktop.
Save MiCurry/33632dbf29fca73ad9989454034ab91f to your computer and use it in GitHub Desktop.
MPAS Nearest Cell
from __future__ import absolute_import, division, print_function
import sys
import argparse
import numpy as np
from netCDF4 import Dataset
from mpas_py.mesh import MeshHandler
from mpas_py.soundings import read_soundings
""" Check to see if the soundings from a MPAS simulation are correct """
parser = argparse.ArgumentParser(description=("Find the cell that is nearest to a given latitude"
" and longitude"))
parser.add_argument('mesh',
help='Mesh file',
type=str)
parser.add_argument('lat',
help='Latitude in degrees',
type=float)
parser.add_argument('lon',
help='Longitude in degrees',
type=float)
args = parser.parse_args()
meshFiles = args.mesh
lat = args.lat
lon = args.lon
mesh = MeshHandler(meshFiles)
mesh.load_grid_vars()
print(mesh.nearest_cell(lat, lon))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment