MCPcopy Create free account
hub / github.com/NCAR/wrf-python / get_filepath

Function get_filepath

src/wrf/util.py:3047–3080  ·  view source on GitHub ↗

Return the file path for the specified object. This is used to return the file path for a netcdf object. If the particular object does not have the appropriate file path information, then one is created based on the timestep in the file. Args: obj: An object. Returns:

(obj)

Source from the content-addressed store, hash-verified

3045
3046
3047def get_filepath(obj):
3048 """Return the file path for the specified object.
3049
3050 This is used to return the file path for a netcdf object. If the
3051 particular object does not have the appropriate file path information,
3052 then one is created based on the timestep in the file.
3053
3054 Args:
3055
3056 obj: An object.
3057
3058 Returns:
3059
3060 :obj:`str`: A string for a file path.
3061
3062 """
3063 try:
3064 path = obj.filepath()
3065 except AttributeError:
3066 try:
3067 path = obj.file.path
3068 except AttributeError:
3069 # Let's make up a filename from the first file time
3070 found = False
3071 times = extract_times(obj, None, meta=False, do_xtime=False)
3072 for t in times:
3073 path = "wrfout_{}".format(str(t))
3074 found = True
3075 break
3076
3077 if not found:
3078 raise ValueError("file contains no path information")
3079
3080 return path
3081
3082
3083def get_id(obj, prefix=''):

Callers 1

get_idFunction · 0.85

Calls 1

extract_timesFunction · 0.85

Tested by

no test coverage detected