Metadata-Version: 2.4
Name: yr_meteogram_util
Version: 0.2.5
Summary: A package for downloading and maniuplating meteograms from YR
Project-URL: Homepage, https://github.com/d95andek/yr_meteogram_util
Project-URL: Issues, https://github.com/d95andek/yr_meteogram_util/issues
Author-email: Andreas Gunnerås <andreas@gunneras.se>
License-Expression: MIT
License-File: LICENSE.txt
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Requires-Python: >=3.10
Requires-Dist: aiohttp>=3.10
Description-Content-Type: text/markdown

# yr_meteogram_util

Python library for fetching and manipulating meteograms from YR.

The meteograms are returned as svg in a string for you to use.

## Installing

To install the package, run:

```pip install yr_meteogram_util```

### To upgrade

To upgrade to the latest version, run:
```pip install --upgrade yr_meteogram_util```

## Features

- Standard (bright) or dark meteograms

  You can select between bright (default) or dark versions of the meteograms.

  Standard:
  
  ![Standard meteogram](https://raw.githubusercontent.com/d95andek/yr_meteogram_util/main/assets/images/Standard.png)

  Dark (as rendered by Safari):

  ![Dark meteogram](https://raw.githubusercontent.com/d95andek/yr_meteogram_util/main/assets/images/Dark.png)

  These are provided exactly as they are generated by Yr.

- Crop

  The default meteograms have quite a lot of empty space, so you can select to have the meteograms cropped into a more compact version.

  ![Cropped meteogram](https://raw.githubusercontent.com/d95andek/yr_meteogram_util/main/assets/images/Cropped.png)

  This is done by altering the generated by Yr and change of generated contents may result in failure or unpredicted results.

- Make transparent

  If you want to display the meteograms someware that has a background color other than white or black, it can be frustrating that they have a white or black background. So, you can choose to remove that and get a transparent meteogram.

  ![Transparent meteogram](https://raw.githubusercontent.com/d95andek/yr_meteogram_util/main/assets/images/Transparent.png)

  This is done by altering the generated by Yr and change of generated contents may result in failure or unpredicted results.

- Unhide

  The dark version from YR renders bad in Safari browers. The logos and the wind direction arrows are rendered as "black on black"... So if you select the dark version the colors are altered to render the same way in Safari as in Chrome and Edge.

  ![Dark meteogram with modified colors](https://raw.githubusercontent.com/d95andek/yr_meteogram_util/main/assets/images/Dark_Unhide.png)

  This is done by altering the generated by Yr and change of generated contents may result in failure or unpredicted results.

- Any combination

  These features are flags and any combination of them can be used. The last one is a dark, cropped, transparent with modified colors.

  ![Dark cropped, transparent meteogram with modified colors](https://raw.githubusercontent.com/d95andek/yr_meteogram_util/main/assets/images/Dark_Transparent_Cropped_Unhide.png)
  

## Notes about location

To find the location id to be able to use this package:
- Navigate to [Yr.no](https://yr.no)
- Search for the location you want
- Copy the location id from the url (see picture below)

  ![LocationId in URL](https://raw.githubusercontent.com/d95andek/yr_meteogram_util/main/assets/images/LocationId.png)

## Example

```python
# Import libraries for fetching meteograms from YR
import asyncio # if using the async version
import yr_meteogram_util

# The location to fetch, see "Notes about location"
LOCATION_ID = '2-5847504'

# Fetch the standard (bright) meteogram for LOCATION_ID
standard_meteogram = yr_meteogram_util.fetch_svg(LOCATION_ID)

# Fetch the dark meteogram for LOCATION_ID
dark_meteogram = yr_meteogram_util.fetch_svg(LOCATION_ID, dark = True)

# Fetch the dark meteogram for LOCATION_ID and crop it
dark_cropped_meteogram = yr_meteogram_util.fetch_svg(LOCATION_ID, dark = True, crop = True)

# Fetch the dark meteogram for LOCATION_ID, crop it and make it transparent
dark_cropped_transparent_meteogram = yr_meteogram_util.fetch_svg(LOCATION_ID, dark = True, crop = True, make_transparent = True)

# Fetch the dark meteogram for LOCATION_ID, crop it and make it transparent and unhide dark details
dark_cropped_transparent_meteogram = yr_meteogram_util.fetch_svg(LOCATION_ID, dark = True, crop = True, make_transparent = True, unhide_dark_objects = True)

# There is also an async version available
meteogram_async = asyncio.run(yr_meteogram_util.fetch_svg_async(LOCATION_ID))

# It is possible to get the Location name from a meteogram
location_name = yr_meteogram_util.get_location_name(standard_meteogram)
```