CentralValleyModeling / pandss

A simplified, unified HEC-DSS Library for Python
https://centralvalleymodeling.github.io/pandss/
5 stars 0 forks source link

Issue with copying dailydata #3

Open HamedZamanisabzi opened 6 months ago

HamedZamanisabzi commented 6 months ago

Hi Zach,

based on our conversation, I had an issue with copying daily data from one DSS file which has an annotation in it (probably causing the issue). Here is the error message: { "name": "ValueError", "message": "time data '' does not match format '%d%b%Y' (match)", "stack": "--------------------------------------------------------------------------- ValueError Traceback (most recent call last) Cell In[22], line 1 ----> 1 pyhecdss.DSSFile(os.path.join(path_data, 'SF_mtz_tide_NAVD.dss')).read_catalog().hvplot.table()

File c:\Users\hzamanis\AppData\Local\anaconda3\Lib\site-packages\pyhecdss\pyhecdss.py:388, in DSSFile.read_catalog(self) 386 df = DSSFile._read_catalog_dsd(fdname) 387 else: --> 388 df = DSSFile._read_catalog_dsc(fdname) 389 return df

File c:\Users\hzamanis\AppData\Local\anaconda3\Lib\site-packages\pyhecdss\pyhecdss.py:339, in DSSFile._read_catalog_dsc(fcname) 337 df[list('ABCDEF')] = df['Record Pathname'].str.split('/', expand=True).iloc[:, 1:7] 338 dfg = df.groupby(['A', 'B', 'C', 'F', 'E']) --> 339 df.D = pd.to_datetime(df.D, format='%d%b%Y') 340 dfmin, dfmax = dfg.min(), dfg.max() 341 tagmax = 'T' + str(dfmax.Tag.astype('str').str[1:].astype('int', errors='ignore').max())

File c:\Users\hzamanis\AppData\Local\anaconda3\Lib\site-packages\pandas\core\tools\datetimes.py:1068, in to_datetime(arg, errors, dayfirst, yearfirst, utc, format, exact, unit, infer_datetime_format, origin, cache) 1066 result = arg.map(cache_array) 1067 else: -> 1068 values = convert_listlike(arg._values, format) 1069 result = arg._constructor(values, index=arg.index, name=arg.name) 1070 elif isinstance(arg, (ABCDataFrame, abc.MutableMapping)):

File c:\Users\hzamanis\AppData\Local\anaconda3\Lib\site-packages\pandas\core\tools\datetimes.py:430, in _convert_listlike_datetimes(arg, format, name, tz, unit, errors, infer_datetime_format, dayfirst, yearfirst, exact) 427 format = None 429 if format is not None: --> 430 res = _to_datetime_with_format( 431 arg, orig_arg, name, tz, format, exact, errors, infer_datetime_format 432 ) 433 if res is not None: 434 return res

File c:\Users\hzamanis\AppData\Local\anaconda3\Lib\site-packages\pandas\core\tools\datetimes.py:538, in _to_datetime_with_format(arg, orig_arg, name, tz, fmt, exact, errors, infer_datetime_format) 535 return _box_as_indexlike(result, utc=utc, name=name) 537 # fallback --> 538 res = _array_strptime_with_fallback( 539 arg, name, tz, fmt, exact, errors, infer_datetime_format 540 ) 541 return res

File c:\Users\hzamanis\AppData\Local\anaconda3\Lib\site-packages\pandas\core\tools\datetimes.py:473, in _array_strptime_with_fallback(arg, name, tz, fmt, exact, errors, infer_datetime_format) 470 utc = tz == \"utc\" 472 try: --> 473 result, timezones = array_strptime(arg, fmt, exact=exact, errors=errors) 474 except OutOfBoundsDatetime: 475 if errors == \"raise\":

File c:\Users\hzamanis\AppData\Local\anaconda3\Lib\site-packages\pandas\_libs\tslibs\strptime.pyx:150, in pandas._libs.tslibs.strptime.array_strptime()

ValueError: time data '' does not match format '%d%b%Y' (match)" }

Thanks, Hamed

HamedZamanisabzi commented 6 months ago

Hi Zach, one more thing I figured out that is: whenever, there is a sign in the naming of F part in the DSS files, we get error for copying them from one DSS file to another using PANDSS lib. For example, whenever, there is a path name such as: "/QUALV8.2.1/CVP_INTAKE/EC//1DAY/CS3V27_EX+FROM-ALL/", we get error in copying those parameters between the DSS files. When I revised that path to: "/QUALV8.2.1/CVP_INTAKE/EC//1DAY/CS3V27_EX/", (removed "+FROM-ALL") from F part of the associated parameters, it worked and was copied.