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

Add custom string formatter for lower/upper support #417

Closed
djhoese opened this issue Sep 14, 2018 · 3 comments
Closed

Add custom string formatter for lower/upper support #417

djhoese opened this issue Sep 14, 2018 · 3 comments
Assignees

Comments

@djhoese
Copy link
Member

djhoese commented Sep 14, 2018

Is your feature request related to a problem? Please describe.
Sometimes a user may want to write to files with a specific naming scheme. The builtin python formatting can get someone pretty far especially thinking about how datetime objects can be formatted. The issue comes when someone has different ideas about capitalization and/or use of hyphens in platform, sensor, and product name (G16, GOES-16, goes-16, goes16, etc). It would be nice if the file pattern could encode some of these types of operations until satpy can do a better job of standardizing names for things. This is especially useful for my Geo2Grid project where users are using the command line and don't modify the python.

Describe the solution you'd like
Follow the solution mentioned here: https://stackoverflow.com/a/17848303/433202
To create a custom string formatter that would support the !u and !l format string to run .upper and .lower on that string argument. I'm not sure how many other ones I would want. Maybe one to remove hyphen, one to replace hyphen with underscore, etc.

Describe any changes to existing user workflow
Nothing changes from what a user can currently do, just added features that would need to be documented.

Additional python or other dependencies
None.

Describe any changes required to the build process
No.

Describe alternatives you've considered
If we standardized platform and sensor across all readers then it would be easier to provide the user a series of keys to choose from like platform_oscar or platform_lower or platform_upper or come up with "standard" ways that things are named (good luck) like platform_nasa. Then the user just puts that in their file pattern: {platform_oscar}_{sensor_lower}_...tif

Additional context
Add any other context or screenshots about the feature request here.

@djhoese djhoese self-assigned this Sep 14, 2018
@pnuu
Copy link
Member

pnuu commented Sep 14, 2018

The actual string formatting is done in trollsift, so maybe the !u and !l functionality should be added there?

@djhoese
Copy link
Member Author

djhoese commented Sep 14, 2018

Good point. Agreed. I'll move the issue over.

@djhoese
Copy link
Member Author

djhoese commented Oct 16, 2018

This has been fixed with trollsift 0.3+. See trollsift documentation for how to customize the filename pattern to use it: https://trollsift.readthedocs.io/en/latest/usage.html#composing

@djhoese djhoese closed this as completed Oct 16, 2018
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

2 participants