-
Notifications
You must be signed in to change notification settings - Fork 4
Get tile #59
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
Merged
Merged
Get tile #59
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
2be4ef2
Add getTile endpoint
akash5100 3e9c897
Fix typos in docstrings
akash5100 601507a
Add getTile endpoint
akash5100 42e7c60
Fix typos in docstrings
akash5100 3237a6d
Rebase with main
akash5100 ddbf35d
Add missing lines in docstring
akash5100 812f15d
Update hvpy/facade.py
akash5100 9e2c63b
doc rendering fix
akash5100 24fcedd
Merge branch 'getTile' of github.com:akash5100/python-api into getTile
akash5100 7cb2080
more visual updates for getTile docs
akash5100 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,80 @@ | ||
| from typing import Optional | ||
| from datetime import datetime | ||
|
|
||
| from pydantic import validator | ||
|
|
||
| from hvpy.io import HvpyParameters, OutputType | ||
| from hvpy.utils import convert_date_to_isoformat | ||
|
|
||
|
|
||
| class getTileInputParameters(HvpyParameters): | ||
| """ | ||
| Handles the input parameters of the ``getTile`` API. | ||
|
|
||
| Attributes | ||
| ---------- | ||
| {Shared} | ||
| id | ||
| Unique image identifier. | ||
| x | ||
| Tile x-coordinate. | ||
| y | ||
| Tile y-coordinate. | ||
| imageScale | ||
| Image scale in arcseconds per pixel. | ||
| difference | ||
| Specify image type difference. | ||
|
|
||
| ``0`` - Display regular image | ||
|
|
||
| ``1`` - Running difference image | ||
|
|
||
| ``2`` - Base difference image | ||
|
|
||
| Default is `None`, optional. | ||
|
|
||
| diffCount | ||
| Used to display Running difference image. Work with “diffTime” parameter and set amount of time to use in time period. | ||
| Default is `None`, optional. | ||
| diffTime | ||
| Select Running difference time period: | ||
|
|
||
| ``1`` - Minutes | ||
|
|
||
| ``2`` - Hours | ||
|
|
||
| ``3`` - Days | ||
|
|
||
| ``4`` - Weeks | ||
|
|
||
| ``5`` - Month | ||
|
|
||
| ``6`` - Years | ||
|
|
||
| Default is `None`, optional. | ||
| baseDiffTime | ||
| Date/Time string for Base difference images. | ||
| Default is `None`, optional. | ||
|
|
||
| References | ||
| ---------- | ||
| * `<https://api.helioviewer.org/docs/v2/api/api_groups/official_clients.html#gettile>`__ | ||
| {Shared} | ||
| """ | ||
|
|
||
| id: int | ||
| x: int | ||
| y: int | ||
| imageScale: int | ||
| difference: Optional[int] = None | ||
| diffCount: Optional[int] = None | ||
| diffTime: Optional[int] = None | ||
| baseDiffTime: Optional[datetime] = None | ||
|
|
||
| _date_vaidator = validator("baseDiffTime", allow_reuse=True)(convert_date_to_isoformat) | ||
|
|
||
| def get_output_type(self) -> OutputType: | ||
| """ | ||
| Returns the output type of the API call. | ||
| """ | ||
| return OutputType.RAW | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| import pytest | ||
|
|
||
| from hvpy import getTile | ||
| from hvpy.api_groups.screenshots.get_tile import getTileInputParameters | ||
|
|
||
|
|
||
| def test_getTile(): | ||
| response = getTile( | ||
| id=36275490, | ||
| x=-1, | ||
| y=-1, | ||
| imageScale=2, | ||
| ) | ||
| assert isinstance(response, bytes) | ||
|
|
||
|
|
||
| def test_error_handling(): | ||
| with pytest.raises(TypeError, match="missing 1 required positional argument: 'id'"): | ||
| getTile( | ||
| x=-1, | ||
| y=-1, | ||
| imageScale=2, | ||
| ) | ||
| with pytest.raises(TypeError, match="missing 1 required positional argument: 'x'"): | ||
| getTile( | ||
| id=36275490, | ||
| y=-1, | ||
| imageScale=2, | ||
| ) | ||
| with pytest.raises(TypeError, match="missing 1 required positional argument: 'y'"): | ||
| getTile( | ||
| id=36275490, | ||
| x=-1, | ||
| imageScale=2, | ||
| ) | ||
| with pytest.raises(TypeError, match="missing 1 required positional argument: 'imageScale'"): | ||
| getTile( | ||
| id=36275490, | ||
| x=-1, | ||
| y=-1, | ||
| ) | ||
|
|
||
|
|
||
| def test_url_property(): | ||
| params = getTileInputParameters( | ||
| id=36275490, | ||
| x=-1, | ||
| y=-1, | ||
| imageScale=2, | ||
| ) | ||
| assert params.url == "https://api.beta.helioviewer.org/v2/getTile/" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.