-
Notifications
You must be signed in to change notification settings - Fork 2
Server Basics
Bill Chen edited this page Mar 25, 2022
·
1 revision
具体的完整定义见 ./server/api/models.py。
- Dataset:单个数据集单位。包含可选的坐标信息,用于在首页的地图上定位。DATASET_TYPE 包括:
class DatasetType(models.TextChoices):
RBR = 'RBR' # 来自 RBR 浮标的数据,如 OBS 浊度计的数据
NCF = 'NCF' # netCDF 格式数据,二维模型
RASTER = 'RT' # 光栅文件数据,要在地图上显示的数据
TABLE = 'TABLE' # 简单的表格数据
GENERAL = 'GNR' # 普通数据,不需要在地图上显示
- VisFile:需要用来可视化的数据集。这些数据集可以在前端访问检索。VisFile 本身不包含时间范围,由其对应的 DataChannel 指定。其中,
first_dimension_name
指定了了第一维度的名称,通常是时间。前端也会以这个维度为字段作为 x 轴。因此通常是 Time, DateTime, Date 等,视数据集体情况而定。FORMAT 包括:
class FileFormat(models.TextChoices):
RSK = 'rsk'
CSV = 'csv'
NCF = 'ncf'
TIFF = 'tiff'
OTHER = 'other'
GeoReferencedType 包括:
class GeoreferencedType(models.TextChoices):
EMBEDDED = 'embedded' # 嵌入进文件的地理坐标信息
EXPLICIT = 'explicit' # 显示声明的地理坐标信息 (通过 longitude1, latitude1, longitude2, latitude2)
NONE = 'none' # 无地理坐标信息
- DataChannel:和 VisFile 多对一。包括从 VisFile 内提取的数据频道及其单位、时间范围。由于大多数数据集都包含时间这一维度,因此将其写入了数据库,方便检索。
- RawFile:只提供下载,不提供可视化的文件。和 Dataset 多对一。如果该文件和 VisFile 相同,则和 VisFile 一对一,提供给前端下载链接。
- SiteUser:系统核心用户,为 Django 内 User 的扩充,增加了若干字段,和 User 一一对应。
需要注意的是,大多数实体除了 id 作为主键外,还有一个 uuid 作为检索键。外部的大多数 API 都使用 uuid 来检索而不是 id 来检索,而服务端内部使用 id 来进行查找、join 等操作。这是为了防止用户使用易猜到的序列 id 来随机访问数据。
Swagger 文档包括 API 的参数及各个参数的信息。
https://sklecvis.billc.io/api/swagger/
举个例子,/api/dataset/ 返回体:
{
"detail": "https://sklecvis.billc.io/api/dataset/f133b7a0-8333-4352-94d8-cccde1c48610/",
"uuid": "f133b7a0-8333-4352-94d8-cccde1c48610",
"name": "RBR 浮标 #5",
"description": "来自 5 号 RBR 浮标的数据。",
"created_at": "2022-03-16T07:43:53.011622Z",
"updated_at": "2022-03-16T18:43:20.541834Z",
"is_public": true,
"is_active": true,
"is_deleted": false,
"is_coordinated": true,
"longitude": 122.05325277777777,
"latitude": 31.357491666666668,
"meta_data": {
"name": "060462_20201111_0937.rsk",
"instrument": [
{
"model": "RBRconcerto",
"serial": 60462,
"firmware_type": 103,
"firmware_version": "1.44"
}
],
"rsk_version": "2.10.0",
"sample_size": 542504
},
"datetime_start": "2020-09-09T14:39:08Z",
"datetime_end": "2020-11-11T09:37:38Z",
"dataset_type": "RBR",
"created_by": 3,
"tags": []
},
/api/dataset/c0c7bebb-288d-4b93-94ab-5f9f00061ccc/ 单个返回体:
{
"id": 18,
"vis_files": [
{
"data_channels": [
{
"uuid": "17751e08-d68b-4b3d-ae15-2c0c6d168f1a",
"shape": null,
"name": "Conductivity",
"label": "conductivity_00",
"description": null,
"unit": "mS/cm",
"unit_symbol": null,
"datetime_start": "2020-09-09T13:31:48Z",
"datetime_end": "2020-11-11T07:32:18Z"
},
{
"uuid": "4904495b-6d98-4122-8b23-707fbd0d8207",
"shape": null,
"name": "Temperature",
"label": "temperature_00",
"description": null,
"unit": "°C",
"unit_symbol": null,
"datetime_start": "2020-09-09T13:31:48Z",
"datetime_end": "2020-11-11T07:32:18Z"
},
{
"uuid": "91ddd2bf-e079-4882-9bfd-b43dba0154db",
"shape": null,
"name": "Pressure",
"label": "pressure_00",
"description": null,
"unit": "dbar",
"unit_symbol": null,
"datetime_start": "2020-09-09T13:31:48Z",
"datetime_end": "2020-11-11T07:32:18Z"
},
{
"uuid": "80ddf361-b3a4-4c9d-9eb2-e2fa91514eb8",
"shape": null,
"name": "Temperature",
"label": "pressuretemperature_00",
"description": null,
"unit": "°C",
"unit_symbol": null,
"datetime_start": "2020-09-09T13:31:48Z",
"datetime_end": "2020-11-11T07:32:18Z"
}
],
"file": null,
"uuid": "35e50cf1-8d59-4a1e-a5ba-546890583df7",
"file_name": "060433_20201111_0732.rsk",
"file_size": 60116992,
"format": "rsk",
"default_sample_count": 100000,
"meta_data": {},
"first_dimension_name": "Time",
"is_georeferenced": false,
"longitude1": 0.0,
"latitude1": 0.0,
"longitude2": 0.0,
"latitude2": 0.0,
"dataset": 18
}
],
"raw_files": [
{
"file": "https://sklecvis.billc.io/media/datasets/vis/060433_20201111_0732_NJOcgfc.rsk",
"uuid": "6fc2b3b4-48bc-48d0-8b5b-ef13ea4787b7",
"file_name": "060433_20201111_0732.rsk",
"file_size": 60116992,
"meta_data": {},
"folder_hierarchy": "/",
"file_same_as_vis": true,
"dataset": 18,
"visfile": 12
}
],
"created_by": {
"uuid": "63980d51-1b7f-46d9-a7a2-3551a77ae6fb",
"display_name": "Administrator",
"affiliation": "East China Normal University",
"country": "China",
"phone": "18801239876",
"address": "No. 3663, North Zhongshan Rd. Putuo District.",
"city": "Shanghai",
"state": "Shanghai",
"is_deleted": false,
"last_login": "2022-03-16T08:53:13.736123Z",
"username": "admin",
"first_name": "",
"last_name": "",
"email": "[email protected]",
"date_joined": "2022-03-15T07:18:23.409458Z"
},
"uuid": "c0c7bebb-288d-4b93-94ab-5f9f00061ccc",
"name": "RBR 浮标 #6",
"description": "来自 6 号 RBR 浮标的数据。",
"created_at": "2022-03-16T07:43:45.690476Z",
"updated_at": "2022-03-16T18:43:20.546274Z",
"is_public": true,
"is_active": true,
"is_deleted": false,
"is_coordinated": true,
"longitude": 121.83483333333334,
"latitude": 31.38111111111111,
"meta_data": {
"name": "060433_20201111_0732.rsk",
"instrument": [
{
"model": "RBRconcerto",
"serial": 60433,
"firmware_type": 103,
"firmware_version": "1.44"
}
],
"rsk_version": "2.10.0",
"sample_size": 542164
},
"datetime_start": "2020-09-09T13:31:48Z",
"datetime_end": "2020-11-11T07:32:18Z",
"dataset_type": "RBR",
"tags": []
}