Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ValueError: Invalid format string #240

Open
Lindsey-D opened this issue May 19, 2024 · 4 comments
Open

ValueError: Invalid format string #240

Lindsey-D opened this issue May 19, 2024 · 4 comments

Comments

@Lindsey-D
Copy link

When I run the example for identification:
EddyId nrt_global_allsat_phy_l4_20220301_20220307.nc 20220301 adt ugos vgos longitude latitude pyeddy/test/ -v DEBUG

I got this error:

Traceback (most recent call last):
File "\?\C:\Users\DLX.conda\envs\cyc\Scripts\EddyId-script.py", line 33, in
sys.exit(load_entry_point('pyEddyTracker==3.6.1+12.gc7430ce', 'console_scripts', 'EddyId')())
File "C:\Users\DLX.conda\envs\cyc\lib\site-packages\py_eddy_tracker\appli\grid.py", line 152, in eddy_id
out_name = date.strftime("%(path)s/%(sign_type)s_%Y%m%dT%H%M%S.nc")
ValueError: Invalid format string

Do you have any suggestions?
Thanks

@AntSimi
Copy link
Owner

AntSimi commented May 20, 2024

Which version of python did you use?

@Lindsey-D
Copy link
Author

Which version of python did you use?

3.8.19

@AntSimi
Copy link
Owner

AntSimi commented May 31, 2024

I can't reproduce error on unix platform

@KMartin0013
Copy link

I think this function "strftime" works differently between Windows and Unix. When I run this in Mac, similar error also emerged. So I try to rewrite the the grid.py as:

>     # out_date_name = date.strftime("%(path)s/%(sign_type)s_%Y%m%dT%H%M%S.nc")
>     out_name = date.strftime("_%Y%m%dT%H%M%S.nc")

and the "def write_file" in observation.py as:

def write_file(
        # self, path="./", filename="%(path)s/%(sign_type)s.nc", zarr_flag=False, **kwargs
        self, path="./", filename=None, zarr_flag=False, **kwargs
    ):
        """Write a netcdf or zarr with eddy obs.
        Zarr is usefull for large dataset > 10M observations

        :param str path: set path variable
        :param str filename: model to store file
        :param bool zarr_flag: If True, method will use zarr format instead of netcdf
        :param dict kwargs: look at :py:meth:`to_zarr` or :py:meth:`to_netcdf`
        """
        # filename = filename % dict(
        #     path=path,
        #     sign_type=self.sign_legend,
        #     prod_time=datetime.now().strftime("%Y%m%d"),
        # )

        if filename == None :
            filename = "%s/%s.nc" % (path, self.sign_legend)
        else:
            filename = "%s/%s" % (path, self.sign_legend) + filename

I don't think it is good, but a compromise for windows/mac. Furthermore, this change may also cause other potential issues (but I haven't met yet). Maybe changing the system to Unix could solve a lot of similar issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants