-
Notifications
You must be signed in to change notification settings - Fork 0
9 update internal format docs #12
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
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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 |
|---|---|---|
| @@ -1,40 +1,82 @@ | ||
| # Forti's internal data format | ||
|
|
||
| Forti uses an internal data format for storing data. This format is used both in the blob storage and by `rawdataforecaster`. It also dictates parts of the contents of the grpc protocol. | ||
| Each area/version consists of one or several separate forecasts grouped by their grid resolution. | ||
| This document is intended for developers who need to read or write Forti’s internal data format directly. | ||
|
|
||
| ## Data for each area/version | ||
| Forti uses an internal data format for storing data. This format is used both in the blob storage and by `rawdataforecaster`. | ||
|
|
||
| Each area/version has one or several grids (strictly speaking, it is not a grid, but a collection of latitude/longitude coordinates within a particular area). Each grid is supposed to have the same geographic extent, but differs in what resolution the grid points in each grid has. | ||
| ## Overview | ||
|
|
||
| The data for each grid resolution is described in a uniquely-named subfolder under `/<area>/<version>/` in the blob storage. The data for each resolution is described below. | ||
| Data is split into areas and versions. | ||
| An area refers to to a limited geographic area, typically the domain of a single forecast model. | ||
| Version numbers are used to identify which forecast for an area is the newest. | ||
| Highest version number is newest. | ||
|
|
||
| Each combination of `area` and `version` has accompanying metadata. These data are described in `DatasetMeta` in [the code](../upload/pkg/fortiblob/collector.go). On the blob store, these data are stored in a file called `complete.json`. | ||
| A single rawdataforecaster instance can serve data from several areas, but only one area for a single request. | ||
| This is done by selecting the area with a grid point which is closest to the requested location. | ||
| It will only ever serve the latest version for each area, as determined by that area's version number. | ||
|
|
||
| The data in the single area is expressed as one or more lists of latitude/longitude values with accompanying data for several parameters. | ||
| If there are more than one list of latitudes and longitudes, they are expected to cover the same area, but with different values for latitude and longitude. | ||
| This allows some parameters to have a different resolution than others, even if the cover the same area. | ||
|
|
||
| ## Format for each grid resolution | ||
| All data for each area/version is placed in a uniquely-named subfolder under `/<area>/<version>/` in the blob storage. | ||
| The structure of this is described below. | ||
|
|
||
| The format consists of four pieces of data: | ||
|
|
||
| * forecast values | ||
| * metadata | ||
| * latitudes | ||
| * longitudes | ||
| ## Object store layout | ||
|
|
||
| ### Forecast values | ||
| Under a single area/version in the blob storage, the following layout is expected: | ||
|
|
||
| The forecast values are the actual values for the forecast. The data is organized so that all values for each location is stored together, one location after the other. Each value in the data is merely a little-endian encoded `int16`, and the meaning of each one is defined in the metadata. | ||
| * complete.json | ||
| * sub-folders, containing the following objects: | ||
| * meta.json | ||
| * data | ||
| * longitude | ||
| * latitude | ||
|
|
||
| On the blob store, these data are stored in a file called `data`. | ||
| ### complete.json | ||
|
|
||
| ### Metadata | ||
| This contains metadata about the area/version itself. | ||
| Its format is described in `DatasetMeta` in [the code](../fortiup/pkg/fortiblob/collector.go). | ||
|
|
||
| The metadata describes the meaning of the forecast values. The data structure is described in `MetaCollection` in [the code](../upload/pkg/fortiblob/collector.go). There is also [an example](../upload/pkg/fortiblob/collector_test.go) available for how to interpret raw data. | ||
| When uploading data to the object store, this is supposed to be the last file uploaded, as its existence will trigger an update on `rawdataforecaster`. | ||
|
|
||
| In the blob store, this is json-encoded in a file called `meta.json`. | ||
| ### Sub-folders | ||
|
|
||
| ### Latitudes and longitudes | ||
| Different data for the same geographic area can have different resolutions. | ||
| This will be expressed as different values for longitude and latitudes. | ||
| For each of these resolutions, a subfolder is made. | ||
|
|
||
| In the blob store, latitudes and longitudes exist in two separate files. These define the lat/lon of each forecast point in the data, and each latitude/longitude is binary encoded as a `float32` in the files. | ||
| The name of this sub-folder is expected to be unique for each set of lat/lon lists. | ||
| For example, the name can be equal to the md5 sum of the concatenated latitude and longitude lists. | ||
|
|
||
| The index of each lat/lon pair matches the index of the forecast in the `data` file. So, if you want to look up the data for latitude/longitude index `x`, that data starts in the data file at index `(x * meta.LocationCount)`. Of course, if you make a lookup into a file, you must multiply this by 2 to account for int16 taking up two bytes. | ||
| Four files are expected to exist here: | ||
|
|
||
| * meta.json | ||
| * longitude | ||
| * latitude | ||
| * data | ||
|
|
||
| #### meta.json | ||
|
|
||
| This describes the meaning of the forecast values. | ||
| The data structure is described in `MetaCollection` in [the code](../fortiup/pkg/fortiblob/collector.go). An example of such data can be found in [the same folder](../fortiup/pkg/fortiblob/collector_test.go) | ||
|
|
||
| #### longitude and latitude | ||
|
|
||
| In the blob store, latitudes and longitudes exist in two separate files. | ||
| These define the lat/lon of each forecast point in the data, and each latitude/longitude is binary encoded as a `float32` in the files. | ||
| The ordering of the values are not important, as long as the same ordering is used in the logintude, latitude and data files. | ||
|
|
||
| #### data | ||
|
|
||
| Data contains the actual values for the forecast. | ||
| It consists of a series of little-endian encoded `ìnt16` values, and their meaning is defined in meta.json. | ||
|
|
||
| To look up data for a specific location, you need two things: | ||
| * An index from the latitude and longitude arrays. | ||
| * The length of the relevant data - this is the metadata's number_of_points value. | ||
|
|
||
| Multiply the two values to get the starting index. | ||
| You can then use the metadata to interpret the relavant values. | ||
| [The example](../fortiup/pkg/fortiblob/collector_test.go) shows how to do the interpretation. |
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
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
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
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
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
Oops, something went wrong.
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.