mesowx / MesoPy

A Python wrapper for the MesoWest environmental data API
MIT License
59 stars 23 forks source link

Datetime Handling #31

Closed ZachHoppinen closed 2 years ago

ZachHoppinen commented 2 years ago

Hi team!

Really enjoying the package. I am working with snow remote sensing and this has been really useful for automating the comparison of our RS results to stations.

I am wondering if it would be possible to add functionality to handle DateTime objects. I was thinking, assuming you provide a DateTime object instead of a string it would run:

def parse_datetime(datetime_obj):
    return datetime_obj.strftime('%Y') + datetime_obj.strftime('%m') + datetime_obj.strftime('%d') + datetime_obj.strftime('%H') + datetime_obj.strftime('%M')
from datetime import datetime
if isinstance(user_input_start, datetime):
    user_input_start = parse_datetime(user_input_start)

Happy to parse it myself just might be nice to handle pandas datetime objects within the package.

blaylockbk commented 2 years ago

Hi @ZachKeskinen, I have a spinoff of this python library called SynopticPy that you might want to try. It works a little differently, but does accept datetime input (it even returns the data as a Pandas DataFrame).



I don't know who maintains this repo anymore. I got your notification because apparently I "watch" it; that must have been from a few years ago. Haha!

ZachHoppinen commented 2 years ago

Hey @blaylockbk

Thanks for the reply. That is good info the repo isn't maintained anymore and explains the datetime issues. I'll migrate over to the SynopticPy and swap the code over since I am just starting at this point.

Thanks!