Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def from_path(cls, path: Union[Path, str]):
if isinstance(path, Path):
path = str(path)
if not os.path.exists(path):
raise IOError(f"File does not exist: {path}")
obj = metview.read(path)
obj.__class__ = cls
return obj
def from_path(cls, path: Union[Path, str]):
if isinstance(path, Path):
path = str(path)
mv_instance = metview.read(path)
dataset = mv_instance.to_dataset()
data_vars = list(dataset.data_vars)
coords = list(
{"lat", "lon", "latitude", "longitude", "latitudes", "longitudes"}
& set(dataset.coords)
)
df = dataset.to_dataframe().reset_index()
df = df[coords + data_vars]
for coord in coords:
df[coord] = df[coord].apply(str)
return cls(df)
def read_geopoints(path: Union[Path, str]):
if isinstance(path, Path):
path = str(path)
if not os.path.exists(path):
raise IOError(f"File does not exist: {path}")
return metview.read(path)