qubitclient 0.0.0.1__py3-none-any.whl → 0.0.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of qubitclient might be problematic. Click here for more details.
- qubitclient/QubitSeg.py +3 -3
- qubitclient/__init__.py +2 -0
- qubitclient/curve/curve_type.py +15 -0
- qubitclient/scope/scope.py +51 -0
- qubitclient/scope/scope_api/__init__.py +8 -0
- qubitclient/scope/scope_api/api/__init__.py +1 -0
- qubitclient/scope/scope_api/api/defined_tasks/__init__.py +1 -0
- qubitclient/scope/scope_api/api/defined_tasks/get_task_result_api_v1_tasks_demo_pk_get.py +155 -0
- qubitclient/scope/scope_api/api/defined_tasks/get_task_result_api_v1_tasks_scope_pk_get.py +155 -0
- qubitclient/scope/scope_api/api/defined_tasks/optpipulse_api_v1_tasks_scope_optpipulse_post.py +218 -0
- qubitclient/scope/scope_api/api/defined_tasks/rabi_api_v1_tasks_scope_rabi_post.py +218 -0
- qubitclient/scope/scope_api/api/defined_tasks/rabicos_api_v1_tasks_scope_rabicospeak_post.py +218 -0
- qubitclient/scope/scope_api/api/defined_tasks/s21peak_api_v1_tasks_scope_s21peak_post.py +218 -0
- qubitclient/scope/scope_api/api/defined_tasks/s21vflux_api_v1_tasks_scope_s21vflux_post.py +218 -0
- qubitclient/scope/scope_api/api/defined_tasks/singleshot_api_v1_tasks_scope_singleshot_post.py +218 -0
- qubitclient/scope/scope_api/api/defined_tasks/spectrum_api_v1_tasks_scope_spectrum_post.py +218 -0
- qubitclient/scope/scope_api/api/defined_tasks/t1fit_api_v1_tasks_scope_t1fit_post.py +218 -0
- qubitclient/scope/scope_api/api/defined_tasks/t1fit_api_v1_tasks_scope_t2fit_post.py +218 -0
- qubitclient/scope/scope_api/client.py +268 -0
- qubitclient/scope/scope_api/errors.py +16 -0
- qubitclient/scope/scope_api/models/__init__.py +27 -0
- qubitclient/scope/scope_api/models/body_optpipulse_api_v1_tasks_scope_optpipulse_post.py +83 -0
- qubitclient/scope/scope_api/models/body_rabi_api_v1_tasks_scope_rabi_post.py +83 -0
- qubitclient/scope/scope_api/models/body_rabicos_api_v1_tasks_scope_rabicospeak_post.py +83 -0
- qubitclient/scope/scope_api/models/body_s21_peak_api_v1_tasks_scope_s21_peak_post.py +83 -0
- qubitclient/scope/scope_api/models/body_s21_vflux_api_v1_tasks_scope_s21_vflux_post.py +83 -0
- qubitclient/scope/scope_api/models/body_singleshot_api_v1_tasks_scope_singleshot_post.py +83 -0
- qubitclient/scope/scope_api/models/body_spectrum_api_v1_tasks_scope_spectrum_post.py +83 -0
- qubitclient/scope/scope_api/models/body_t1_fit_api_v1_tasks_scope_t1_fit_post.py +83 -0
- qubitclient/scope/scope_api/models/body_t1_fit_api_v1_tasks_scope_t2_fit_post.py +83 -0
- qubitclient/scope/scope_api/models/http_validation_error.py +75 -0
- qubitclient/scope/scope_api/models/validation_error.py +88 -0
- qubitclient/scope/scope_api/py.typed +1 -0
- qubitclient/scope/scope_api/types.py +54 -0
- qubitclient/scope/task.py +140 -0
- qubitclient/scope/utils/__init__.py +0 -0
- qubitclient/scope/utils/data_parser.py +20 -0
- qubitclient/utils/data_convert.py +112 -0
- qubitclient/utils/data_parser.py +41 -0
- qubitclient/utils/request_tool.py +41 -0
- qubitclient/utils/result_parser.py +55 -0
- qubitclient-0.0.1.dist-info/METADATA +106 -0
- qubitclient-0.0.1.dist-info/RECORD +47 -0
- qubitclient-0.0.0.1.dist-info/METADATA +0 -35
- qubitclient-0.0.0.1.dist-info/RECORD +0 -8
- {qubitclient-0.0.0.1.dist-info → qubitclient-0.0.1.dist-info}/WHEEL +0 -0
- {qubitclient-0.0.0.1.dist-info → qubitclient-0.0.1.dist-info}/licenses/LICENSE +0 -0
- {qubitclient-0.0.0.1.dist-info → qubitclient-0.0.1.dist-info}/top_level.txt +0 -0
- {qubitclient-0.0.0.1.dist-info → qubitclient-0.0.1.dist-info}/zip-safe +0 -0
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
from collections.abc import Mapping
|
|
2
|
+
from io import BytesIO
|
|
3
|
+
from typing import Any, TypeVar
|
|
4
|
+
|
|
5
|
+
from attrs import define as _attrs_define
|
|
6
|
+
from attrs import field as _attrs_field
|
|
7
|
+
|
|
8
|
+
from .. import types
|
|
9
|
+
from ..types import File
|
|
10
|
+
|
|
11
|
+
T = TypeVar("T", bound="BodyT1FitApiV1TasksScopeT1FitPost")
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
@_attrs_define
|
|
15
|
+
class BodyT1FitApiV1TasksScopeT1FitPost:
|
|
16
|
+
"""
|
|
17
|
+
Attributes:
|
|
18
|
+
files (list[File]):
|
|
19
|
+
"""
|
|
20
|
+
|
|
21
|
+
files: list[File]
|
|
22
|
+
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
|
|
23
|
+
|
|
24
|
+
def to_dict(self) -> dict[str, Any]:
|
|
25
|
+
files = []
|
|
26
|
+
for files_item_data in self.files:
|
|
27
|
+
files_item = files_item_data.to_tuple()
|
|
28
|
+
|
|
29
|
+
files.append(files_item)
|
|
30
|
+
|
|
31
|
+
field_dict: dict[str, Any] = {}
|
|
32
|
+
field_dict.update(self.additional_properties)
|
|
33
|
+
field_dict.update(
|
|
34
|
+
{
|
|
35
|
+
"files": files,
|
|
36
|
+
}
|
|
37
|
+
)
|
|
38
|
+
|
|
39
|
+
return field_dict
|
|
40
|
+
|
|
41
|
+
def to_multipart(self) -> types.RequestFiles:
|
|
42
|
+
files: types.RequestFiles = []
|
|
43
|
+
|
|
44
|
+
for files_item_element in self.files:
|
|
45
|
+
files.append(("files", files_item_element.to_tuple()))
|
|
46
|
+
|
|
47
|
+
for prop_name, prop in self.additional_properties.items():
|
|
48
|
+
files.append((prop_name, (None, str(prop).encode(), "text/plain")))
|
|
49
|
+
|
|
50
|
+
return files
|
|
51
|
+
|
|
52
|
+
@classmethod
|
|
53
|
+
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
|
|
54
|
+
d = dict(src_dict)
|
|
55
|
+
files = []
|
|
56
|
+
_files = d.pop("files")
|
|
57
|
+
for files_item_data in _files:
|
|
58
|
+
files_item = File(payload=BytesIO(files_item_data))
|
|
59
|
+
|
|
60
|
+
files.append(files_item)
|
|
61
|
+
|
|
62
|
+
body_t1_fit_api_v1_tasks_scope_t1_fit_post = cls(
|
|
63
|
+
files=files,
|
|
64
|
+
)
|
|
65
|
+
|
|
66
|
+
body_t1_fit_api_v1_tasks_scope_t1_fit_post.additional_properties = d
|
|
67
|
+
return body_t1_fit_api_v1_tasks_scope_t1_fit_post
|
|
68
|
+
|
|
69
|
+
@property
|
|
70
|
+
def additional_keys(self) -> list[str]:
|
|
71
|
+
return list(self.additional_properties.keys())
|
|
72
|
+
|
|
73
|
+
def __getitem__(self, key: str) -> Any:
|
|
74
|
+
return self.additional_properties[key]
|
|
75
|
+
|
|
76
|
+
def __setitem__(self, key: str, value: Any) -> None:
|
|
77
|
+
self.additional_properties[key] = value
|
|
78
|
+
|
|
79
|
+
def __delitem__(self, key: str) -> None:
|
|
80
|
+
del self.additional_properties[key]
|
|
81
|
+
|
|
82
|
+
def __contains__(self, key: str) -> bool:
|
|
83
|
+
return key in self.additional_properties
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
from collections.abc import Mapping
|
|
2
|
+
from io import BytesIO
|
|
3
|
+
from typing import Any, TypeVar
|
|
4
|
+
|
|
5
|
+
from attrs import define as _attrs_define
|
|
6
|
+
from attrs import field as _attrs_field
|
|
7
|
+
|
|
8
|
+
from .. import types
|
|
9
|
+
from ..types import File
|
|
10
|
+
|
|
11
|
+
T = TypeVar("T", bound="BodyT1FitApiV1TasksScopeT2FitPost")
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
@_attrs_define
|
|
15
|
+
class BodyT1FitApiV1TasksScopeT2FitPost:
|
|
16
|
+
"""
|
|
17
|
+
Attributes:
|
|
18
|
+
files (list[File]):
|
|
19
|
+
"""
|
|
20
|
+
|
|
21
|
+
files: list[File]
|
|
22
|
+
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
|
|
23
|
+
|
|
24
|
+
def to_dict(self) -> dict[str, Any]:
|
|
25
|
+
files = []
|
|
26
|
+
for files_item_data in self.files:
|
|
27
|
+
files_item = files_item_data.to_tuple()
|
|
28
|
+
|
|
29
|
+
files.append(files_item)
|
|
30
|
+
|
|
31
|
+
field_dict: dict[str, Any] = {}
|
|
32
|
+
field_dict.update(self.additional_properties)
|
|
33
|
+
field_dict.update(
|
|
34
|
+
{
|
|
35
|
+
"files": files,
|
|
36
|
+
}
|
|
37
|
+
)
|
|
38
|
+
|
|
39
|
+
return field_dict
|
|
40
|
+
|
|
41
|
+
def to_multipart(self) -> types.RequestFiles:
|
|
42
|
+
files: types.RequestFiles = []
|
|
43
|
+
|
|
44
|
+
for files_item_element in self.files:
|
|
45
|
+
files.append(("files", files_item_element.to_tuple()))
|
|
46
|
+
|
|
47
|
+
for prop_name, prop in self.additional_properties.items():
|
|
48
|
+
files.append((prop_name, (None, str(prop).encode(), "text/plain")))
|
|
49
|
+
|
|
50
|
+
return files
|
|
51
|
+
|
|
52
|
+
@classmethod
|
|
53
|
+
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
|
|
54
|
+
d = dict(src_dict)
|
|
55
|
+
files = []
|
|
56
|
+
_files = d.pop("files")
|
|
57
|
+
for files_item_data in _files:
|
|
58
|
+
files_item = File(payload=BytesIO(files_item_data))
|
|
59
|
+
|
|
60
|
+
files.append(files_item)
|
|
61
|
+
|
|
62
|
+
body_t1_fit_api_v1_tasks_scope_t2_fit_post = cls(
|
|
63
|
+
files=files,
|
|
64
|
+
)
|
|
65
|
+
|
|
66
|
+
body_t1_fit_api_v1_tasks_scope_t2_fit_post.additional_properties = d
|
|
67
|
+
return body_t1_fit_api_v1_tasks_scope_t2_fit_post
|
|
68
|
+
|
|
69
|
+
@property
|
|
70
|
+
def additional_keys(self) -> list[str]:
|
|
71
|
+
return list(self.additional_properties.keys())
|
|
72
|
+
|
|
73
|
+
def __getitem__(self, key: str) -> Any:
|
|
74
|
+
return self.additional_properties[key]
|
|
75
|
+
|
|
76
|
+
def __setitem__(self, key: str, value: Any) -> None:
|
|
77
|
+
self.additional_properties[key] = value
|
|
78
|
+
|
|
79
|
+
def __delitem__(self, key: str) -> None:
|
|
80
|
+
del self.additional_properties[key]
|
|
81
|
+
|
|
82
|
+
def __contains__(self, key: str) -> bool:
|
|
83
|
+
return key in self.additional_properties
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
from collections.abc import Mapping
|
|
2
|
+
from typing import TYPE_CHECKING, Any, TypeVar, Union
|
|
3
|
+
|
|
4
|
+
from attrs import define as _attrs_define
|
|
5
|
+
from attrs import field as _attrs_field
|
|
6
|
+
|
|
7
|
+
from ..types import UNSET, Unset
|
|
8
|
+
|
|
9
|
+
if TYPE_CHECKING:
|
|
10
|
+
from ..models.validation_error import ValidationError
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
T = TypeVar("T", bound="HTTPValidationError")
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
@_attrs_define
|
|
17
|
+
class HTTPValidationError:
|
|
18
|
+
"""
|
|
19
|
+
Attributes:
|
|
20
|
+
detail (Union[Unset, list['ValidationError']]):
|
|
21
|
+
"""
|
|
22
|
+
|
|
23
|
+
detail: Union[Unset, list["ValidationError"]] = UNSET
|
|
24
|
+
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
|
|
25
|
+
|
|
26
|
+
def to_dict(self) -> dict[str, Any]:
|
|
27
|
+
detail: Union[Unset, list[dict[str, Any]]] = UNSET
|
|
28
|
+
if not isinstance(self.detail, Unset):
|
|
29
|
+
detail = []
|
|
30
|
+
for detail_item_data in self.detail:
|
|
31
|
+
detail_item = detail_item_data.to_dict()
|
|
32
|
+
detail.append(detail_item)
|
|
33
|
+
|
|
34
|
+
field_dict: dict[str, Any] = {}
|
|
35
|
+
field_dict.update(self.additional_properties)
|
|
36
|
+
field_dict.update({})
|
|
37
|
+
if detail is not UNSET:
|
|
38
|
+
field_dict["detail"] = detail
|
|
39
|
+
|
|
40
|
+
return field_dict
|
|
41
|
+
|
|
42
|
+
@classmethod
|
|
43
|
+
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
|
|
44
|
+
from ..models.validation_error import ValidationError
|
|
45
|
+
|
|
46
|
+
d = dict(src_dict)
|
|
47
|
+
detail = []
|
|
48
|
+
_detail = d.pop("detail", UNSET)
|
|
49
|
+
for detail_item_data in _detail or []:
|
|
50
|
+
detail_item = ValidationError.from_dict(detail_item_data)
|
|
51
|
+
|
|
52
|
+
detail.append(detail_item)
|
|
53
|
+
|
|
54
|
+
http_validation_error = cls(
|
|
55
|
+
detail=detail,
|
|
56
|
+
)
|
|
57
|
+
|
|
58
|
+
http_validation_error.additional_properties = d
|
|
59
|
+
return http_validation_error
|
|
60
|
+
|
|
61
|
+
@property
|
|
62
|
+
def additional_keys(self) -> list[str]:
|
|
63
|
+
return list(self.additional_properties.keys())
|
|
64
|
+
|
|
65
|
+
def __getitem__(self, key: str) -> Any:
|
|
66
|
+
return self.additional_properties[key]
|
|
67
|
+
|
|
68
|
+
def __setitem__(self, key: str, value: Any) -> None:
|
|
69
|
+
self.additional_properties[key] = value
|
|
70
|
+
|
|
71
|
+
def __delitem__(self, key: str) -> None:
|
|
72
|
+
del self.additional_properties[key]
|
|
73
|
+
|
|
74
|
+
def __contains__(self, key: str) -> bool:
|
|
75
|
+
return key in self.additional_properties
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
from collections.abc import Mapping
|
|
2
|
+
from typing import Any, TypeVar, Union, cast
|
|
3
|
+
|
|
4
|
+
from attrs import define as _attrs_define
|
|
5
|
+
from attrs import field as _attrs_field
|
|
6
|
+
|
|
7
|
+
T = TypeVar("T", bound="ValidationError")
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
@_attrs_define
|
|
11
|
+
class ValidationError:
|
|
12
|
+
"""
|
|
13
|
+
Attributes:
|
|
14
|
+
loc (list[Union[int, str]]):
|
|
15
|
+
msg (str):
|
|
16
|
+
type_ (str):
|
|
17
|
+
"""
|
|
18
|
+
|
|
19
|
+
loc: list[Union[int, str]]
|
|
20
|
+
msg: str
|
|
21
|
+
type_: str
|
|
22
|
+
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
|
|
23
|
+
|
|
24
|
+
def to_dict(self) -> dict[str, Any]:
|
|
25
|
+
loc = []
|
|
26
|
+
for loc_item_data in self.loc:
|
|
27
|
+
loc_item: Union[int, str]
|
|
28
|
+
loc_item = loc_item_data
|
|
29
|
+
loc.append(loc_item)
|
|
30
|
+
|
|
31
|
+
msg = self.msg
|
|
32
|
+
|
|
33
|
+
type_ = self.type_
|
|
34
|
+
|
|
35
|
+
field_dict: dict[str, Any] = {}
|
|
36
|
+
field_dict.update(self.additional_properties)
|
|
37
|
+
field_dict.update(
|
|
38
|
+
{
|
|
39
|
+
"loc": loc,
|
|
40
|
+
"msg": msg,
|
|
41
|
+
"type": type_,
|
|
42
|
+
}
|
|
43
|
+
)
|
|
44
|
+
|
|
45
|
+
return field_dict
|
|
46
|
+
|
|
47
|
+
@classmethod
|
|
48
|
+
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
|
|
49
|
+
d = dict(src_dict)
|
|
50
|
+
loc = []
|
|
51
|
+
_loc = d.pop("loc")
|
|
52
|
+
for loc_item_data in _loc:
|
|
53
|
+
|
|
54
|
+
def _parse_loc_item(data: object) -> Union[int, str]:
|
|
55
|
+
return cast(Union[int, str], data)
|
|
56
|
+
|
|
57
|
+
loc_item = _parse_loc_item(loc_item_data)
|
|
58
|
+
|
|
59
|
+
loc.append(loc_item)
|
|
60
|
+
|
|
61
|
+
msg = d.pop("msg")
|
|
62
|
+
|
|
63
|
+
type_ = d.pop("type")
|
|
64
|
+
|
|
65
|
+
validation_error = cls(
|
|
66
|
+
loc=loc,
|
|
67
|
+
msg=msg,
|
|
68
|
+
type_=type_,
|
|
69
|
+
)
|
|
70
|
+
|
|
71
|
+
validation_error.additional_properties = d
|
|
72
|
+
return validation_error
|
|
73
|
+
|
|
74
|
+
@property
|
|
75
|
+
def additional_keys(self) -> list[str]:
|
|
76
|
+
return list(self.additional_properties.keys())
|
|
77
|
+
|
|
78
|
+
def __getitem__(self, key: str) -> Any:
|
|
79
|
+
return self.additional_properties[key]
|
|
80
|
+
|
|
81
|
+
def __setitem__(self, key: str, value: Any) -> None:
|
|
82
|
+
self.additional_properties[key] = value
|
|
83
|
+
|
|
84
|
+
def __delitem__(self, key: str) -> None:
|
|
85
|
+
del self.additional_properties[key]
|
|
86
|
+
|
|
87
|
+
def __contains__(self, key: str) -> bool:
|
|
88
|
+
return key in self.additional_properties
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# Marker file for PEP 561
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"""Contains some shared types for properties"""
|
|
2
|
+
|
|
3
|
+
from collections.abc import Mapping, MutableMapping
|
|
4
|
+
from http import HTTPStatus
|
|
5
|
+
from typing import IO, BinaryIO, Generic, Literal, Optional, TypeVar, Union
|
|
6
|
+
|
|
7
|
+
from attrs import define
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class Unset:
|
|
11
|
+
def __bool__(self) -> Literal[False]:
|
|
12
|
+
return False
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
UNSET: Unset = Unset()
|
|
16
|
+
|
|
17
|
+
# The types that `httpx.Client(files=)` can accept, copied from that library.
|
|
18
|
+
FileContent = Union[IO[bytes], bytes, str]
|
|
19
|
+
FileTypes = Union[
|
|
20
|
+
# (filename, file (or bytes), content_type)
|
|
21
|
+
tuple[Optional[str], FileContent, Optional[str]],
|
|
22
|
+
# (filename, file (or bytes), content_type, headers)
|
|
23
|
+
tuple[Optional[str], FileContent, Optional[str], Mapping[str, str]],
|
|
24
|
+
]
|
|
25
|
+
RequestFiles = list[tuple[str, FileTypes]]
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
@define
|
|
29
|
+
class File:
|
|
30
|
+
"""Contains information for file uploads"""
|
|
31
|
+
|
|
32
|
+
payload: BinaryIO
|
|
33
|
+
file_name: Optional[str] = None
|
|
34
|
+
mime_type: Optional[str] = None
|
|
35
|
+
|
|
36
|
+
def to_tuple(self) -> FileTypes:
|
|
37
|
+
"""Return a tuple representation that httpx will accept for multipart/form-data"""
|
|
38
|
+
return self.file_name, self.payload, self.mime_type
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
T = TypeVar("T")
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
@define
|
|
45
|
+
class Response(Generic[T]):
|
|
46
|
+
"""A response from an endpoint"""
|
|
47
|
+
|
|
48
|
+
status_code: HTTPStatus
|
|
49
|
+
content: bytes
|
|
50
|
+
headers: MutableMapping[str, str]
|
|
51
|
+
parsed: Optional[T]
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
__all__ = ["UNSET", "File", "FileTypes", "RequestFiles", "Response", "Unset"]
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
from .scope_api.api.defined_tasks import s21peak_api_v1_tasks_scope_s21peak_post
|
|
4
|
+
from .scope_api.api.defined_tasks import optpipulse_api_v1_tasks_scope_optpipulse_post
|
|
5
|
+
from .scope_api.api.defined_tasks import rabi_api_v1_tasks_scope_rabi_post
|
|
6
|
+
from .scope_api.api.defined_tasks import rabicos_api_v1_tasks_scope_rabicospeak_post
|
|
7
|
+
from .scope_api.api.defined_tasks import s21vflux_api_v1_tasks_scope_s21vflux_post
|
|
8
|
+
from .scope_api.api.defined_tasks import singleshot_api_v1_tasks_scope_singleshot_post
|
|
9
|
+
from .scope_api.api.defined_tasks import spectrum_api_v1_tasks_scope_spectrum_post
|
|
10
|
+
from .scope_api.api.defined_tasks import t1fit_api_v1_tasks_scope_t1fit_post
|
|
11
|
+
from .scope_api.api.defined_tasks import t1fit_api_v1_tasks_scope_t2fit_post
|
|
12
|
+
|
|
13
|
+
from .scope_api.models import BodyS21PeakApiV1TasksScopeS21PeakPost
|
|
14
|
+
from .scope_api.models import BodyOptpipulseApiV1TasksScopeOptpipulsePost
|
|
15
|
+
from .scope_api.models import BodyRabiApiV1TasksScopeRabiPost
|
|
16
|
+
from .scope_api.models import BodyRabicosApiV1TasksScopeRabicospeakPost
|
|
17
|
+
from .scope_api.models import BodyS21VfluxApiV1TasksScopeS21VfluxPost
|
|
18
|
+
from .scope_api.models import BodySingleshotApiV1TasksScopeSingleshotPost
|
|
19
|
+
from .scope_api.models import BodySpectrumApiV1TasksScopeSpectrumPost
|
|
20
|
+
from .scope_api.models import BodyT1FitApiV1TasksScopeT1FitPost
|
|
21
|
+
from .scope_api.models import BodyT1FitApiV1TasksScopeT2FitPost
|
|
22
|
+
|
|
23
|
+
from .scope_api.types import Response
|
|
24
|
+
from .scope_api.types import File
|
|
25
|
+
|
|
26
|
+
import io
|
|
27
|
+
import numpy as np
|
|
28
|
+
def load_from_dict(dict_list: list[dict]):
|
|
29
|
+
files = []
|
|
30
|
+
for index, dict_obj in enumerate(dict_list):
|
|
31
|
+
with io.BytesIO() as buffer:
|
|
32
|
+
np.savez(buffer, **dict_obj)
|
|
33
|
+
bytes_obj = buffer.getvalue()
|
|
34
|
+
# 假设File类定义如下:
|
|
35
|
+
# File(payload=bytes内容, file_name=字符串)
|
|
36
|
+
files.append(File(payload=bytes_obj, file_name=f"file_{index}.npz"))
|
|
37
|
+
return files
|
|
38
|
+
|
|
39
|
+
def load_from_ndarray(ndarray_list: list[np.ndarray]):
|
|
40
|
+
files = []
|
|
41
|
+
for idx, ndarray_data in enumerate(ndarray_list):
|
|
42
|
+
buffer = io.BytesIO()
|
|
43
|
+
np.save(buffer, ndarray_data)
|
|
44
|
+
buffer.seek(0)
|
|
45
|
+
files.append(File(payload=buffer.read(), file_name=f"file_{idx}.npz"))
|
|
46
|
+
return files
|
|
47
|
+
|
|
48
|
+
def load_from_path(filepath_list: list[str]):
|
|
49
|
+
files = []
|
|
50
|
+
for file_path in filepath_list:
|
|
51
|
+
with open(file_path, "rb") as f:
|
|
52
|
+
file_content = f.read()
|
|
53
|
+
files.append(File(payload=file_content, file_name=file_path))
|
|
54
|
+
return files
|
|
55
|
+
def load_files(filepath_list: list[str|dict[str,np.ndarray]|np.ndarray]):
|
|
56
|
+
if len(filepath_list)<=0:
|
|
57
|
+
return []
|
|
58
|
+
else:
|
|
59
|
+
if isinstance(filepath_list[0], dict):
|
|
60
|
+
return load_from_dict(filepath_list)
|
|
61
|
+
elif isinstance(filepath_list[0], np.ndarray):
|
|
62
|
+
return load_from_ndarray(filepath_list)
|
|
63
|
+
elif isinstance(filepath_list[0], str):
|
|
64
|
+
return load_from_path(filepath_list)
|
|
65
|
+
|
|
66
|
+
DEFINED_TASKS = {}
|
|
67
|
+
def task_register(func):
|
|
68
|
+
DEFINED_TASKS[func.__name__.lower()] = func
|
|
69
|
+
return func
|
|
70
|
+
|
|
71
|
+
def run_task(client,file_list: list[str|dict[str,np.ndarray]|np.ndarray],task_type:str):
|
|
72
|
+
files = load_files(file_list)
|
|
73
|
+
response = DEFINED_TASKS[task_type.value](client,files)
|
|
74
|
+
return response
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
@task_register
|
|
78
|
+
def s21peak(client,files: File):
|
|
79
|
+
body: BodyS21PeakApiV1TasksScopeS21PeakPost = BodyS21PeakApiV1TasksScopeS21PeakPost(files=files)
|
|
80
|
+
response: Response[BodyS21PeakApiV1TasksScopeS21PeakPost] = s21peak_api_v1_tasks_scope_s21peak_post.sync_detailed(client=client,body=body)
|
|
81
|
+
return response
|
|
82
|
+
@task_register
|
|
83
|
+
def optpipulse(client,files: File):
|
|
84
|
+
body: BodyOptpipulseApiV1TasksScopeOptpipulsePost = BodyOptpipulseApiV1TasksScopeOptpipulsePost(files=files)
|
|
85
|
+
response: Response[BodyOptpipulseApiV1TasksScopeOptpipulsePost] = optpipulse_api_v1_tasks_scope_optpipulse_post.sync_detailed(client=client,body=body)
|
|
86
|
+
return response
|
|
87
|
+
@task_register
|
|
88
|
+
def rabi(client,files: File):
|
|
89
|
+
body: BodyRabiApiV1TasksScopeRabiPost = BodyRabiApiV1TasksScopeRabiPost(files=files)
|
|
90
|
+
response: Response[BodyRabiApiV1TasksScopeRabiPost] = rabi_api_v1_tasks_scope_rabi_post.sync_detailed(client=client,body=body)
|
|
91
|
+
return response
|
|
92
|
+
@task_register
|
|
93
|
+
def rabicos(client,files: File):
|
|
94
|
+
body: BodyRabicosApiV1TasksScopeRabicospeakPost = BodyRabicosApiV1TasksScopeRabicospeakPost(files=files)
|
|
95
|
+
response: Response[BodyRabicosApiV1TasksScopeRabicospeakPost] = rabicos_api_v1_tasks_scope_rabicospeak_post.sync_detailed(client=client,body=body)
|
|
96
|
+
return response
|
|
97
|
+
@task_register
|
|
98
|
+
def s21vflux(client,files: File):
|
|
99
|
+
body: BodyS21VfluxApiV1TasksScopeS21VfluxPost = BodyS21VfluxApiV1TasksScopeS21VfluxPost(files=files)
|
|
100
|
+
response: Response[BodyS21VfluxApiV1TasksScopeS21VfluxPost] = s21vflux_api_v1_tasks_scope_s21vflux_post.sync_detailed(client=client,body=body)
|
|
101
|
+
return response
|
|
102
|
+
@task_register
|
|
103
|
+
def singleshot(client,files: File):
|
|
104
|
+
body: BodySingleshotApiV1TasksScopeSingleshotPost = BodySingleshotApiV1TasksScopeSingleshotPost(files=files)
|
|
105
|
+
response: Response[BodySingleshotApiV1TasksScopeSingleshotPost] = singleshot_api_v1_tasks_scope_singleshot_post.sync_detailed(client=client,body=body)
|
|
106
|
+
return response
|
|
107
|
+
@task_register
|
|
108
|
+
def spectrum(client,files: File):
|
|
109
|
+
body: BodySpectrumApiV1TasksScopeSpectrumPost = BodySpectrumApiV1TasksScopeSpectrumPost(files=files)
|
|
110
|
+
response: Response[BodySpectrumApiV1TasksScopeSpectrumPost] = spectrum_api_v1_tasks_scope_spectrum_post.sync_detailed(client=client,body=body)
|
|
111
|
+
return response
|
|
112
|
+
@task_register
|
|
113
|
+
def t1fit(client,files: File):
|
|
114
|
+
body: BodyT1FitApiV1TasksScopeT1FitPost = BodyT1FitApiV1TasksScopeT1FitPost(files=files)
|
|
115
|
+
response: Response[BodyT1FitApiV1TasksScopeT1FitPost] = t1fit_api_v1_tasks_scope_t1fit_post.sync_detailed(client=client,body=body)
|
|
116
|
+
return response
|
|
117
|
+
@task_register
|
|
118
|
+
def t2fit(client,files: File):
|
|
119
|
+
body: BodyT1FitApiV1TasksScopeT2FitPost = BodyT1FitApiV1TasksScopeT2FitPost(files=files)
|
|
120
|
+
response: Response[BodyT1FitApiV1TasksScopeT2FitPost] = t1fit_api_v1_tasks_scope_t2fit_post.sync_detailed(client=client,body=body)
|
|
121
|
+
return response
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
from enum import Enum, unique
|
|
126
|
+
@unique
|
|
127
|
+
class TaskName(Enum):
|
|
128
|
+
S21PEAK = "s21peak"
|
|
129
|
+
OPTPIPULSE = "optpipulse"
|
|
130
|
+
RABI = "rabi"
|
|
131
|
+
RABICOS = "rabicos"
|
|
132
|
+
S21VFLUX = "s21vflux"
|
|
133
|
+
SINGLESHOT = "singleshot"
|
|
134
|
+
SPECTRUM = "spectrum"
|
|
135
|
+
T1FIT = "t1fit"
|
|
136
|
+
T2FIT = "t2fit"
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
|
|
File without changes
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
# Copyright (c) 2025 yaqiang.sun.
|
|
3
|
+
# This source code is licensed under the license found in the LICENSE file
|
|
4
|
+
# in the root directory of this source tree.
|
|
5
|
+
#########################################################################
|
|
6
|
+
# Author: yaqiangsun
|
|
7
|
+
# Created Time: 2025/04/11 17:58:29
|
|
8
|
+
########################################################################
|
|
9
|
+
|
|
10
|
+
import os
|
|
11
|
+
import numpy as np
|
|
12
|
+
import cv2
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def load_npy_file(file_path):
|
|
16
|
+
try:
|
|
17
|
+
array = np.load(file_path, allow_pickle=True)
|
|
18
|
+
return array
|
|
19
|
+
except Exception as e:
|
|
20
|
+
raise ValueError(f"加载文件 {file_path} 时出错: {str(e)}")
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
# Copyright (c) 2025 yaqiang.sun.
|
|
3
|
+
# This source code is licensed under the license found in the LICENSE file
|
|
4
|
+
# in the root directory of this source tree.
|
|
5
|
+
#########################################################################
|
|
6
|
+
# Author: yaqiangsun
|
|
7
|
+
# Created Time: 2025/10/24 15:54:07
|
|
8
|
+
########################################################################
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
import numpy as np
|
|
12
|
+
import io
|
|
13
|
+
import os
|
|
14
|
+
import numpy as np
|
|
15
|
+
import cv2
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def load_npz_file(file_path):
|
|
19
|
+
with np.load(file_path, allow_pickle=True) as data: # 修改:添加 allow_pickle=True 参数
|
|
20
|
+
# file_contents[file_name] = dict(data) # 将 .npz 文件内容转换为字典
|
|
21
|
+
content = dict(data) # 将 .npz 文件内容转换为字典
|
|
22
|
+
return content
|
|
23
|
+
def convert_data_to_image(npz_content):
|
|
24
|
+
content = npz_content
|
|
25
|
+
iq_avg = content["iq_avg"] # 二维数据
|
|
26
|
+
iq_avg_normalized = convert_complex_map__to_image(iq_avg=iq_avg)
|
|
27
|
+
return iq_avg_normalized
|
|
28
|
+
def convert_complex_map__to_image(iq_avg):
|
|
29
|
+
# 检查并转置
|
|
30
|
+
rows, cols = iq_avg.shape
|
|
31
|
+
if rows < cols:
|
|
32
|
+
iq_avg = iq_avg.T # 转置矩阵
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
# 取相位
|
|
36
|
+
phase = np.angle(iq_avg)
|
|
37
|
+
phase_normalized = ((phase + np.pi) / (2 * np.pi)) * 255
|
|
38
|
+
# 纵向归一化
|
|
39
|
+
phase_mean = phase_normalized.mean(axis=0, keepdims=True) # 形状(1,30)
|
|
40
|
+
ppase_std = phase_normalized.std(axis=0, keepdims=True) # 形状(1,30)
|
|
41
|
+
phase_normalized = (phase_normalized - phase_mean) / (ppase_std+1e-8)
|
|
42
|
+
# phase_normalized = phase_normalized.astype(np.uint8)
|
|
43
|
+
# 全局归一化
|
|
44
|
+
phase_normalized = cv2.normalize(phase_normalized, None, 0, 255, cv2.NORM_MINMAX, cv2.CV_8U)
|
|
45
|
+
|
|
46
|
+
# 取幅度
|
|
47
|
+
iq_avg = np.abs(iq_avg)
|
|
48
|
+
|
|
49
|
+
# iq_avg = phase_normalized
|
|
50
|
+
# 纵向归一化
|
|
51
|
+
# mean = iq_avg.mean(axis=0, keepdims=True) # 形状(1,30)
|
|
52
|
+
# std = iq_avg.std(axis=0, keepdims=True) # 形状(1,30)
|
|
53
|
+
# iq_avg = (iq_avg - mean) / (std+1e-8)
|
|
54
|
+
# 幅度全局归一化
|
|
55
|
+
iq_avg_normalized = cv2.normalize(iq_avg, None, 0, 255, cv2.NORM_MINMAX, cv2.CV_8U)
|
|
56
|
+
# return iq_avg_normalized
|
|
57
|
+
|
|
58
|
+
#取幅度的梯度
|
|
59
|
+
gradient_y, gradient_x = np.gradient(iq_avg)
|
|
60
|
+
gradient_y = np.abs(gradient_y)
|
|
61
|
+
gradient_y_normalized = cv2.normalize(gradient_y, None, 0, 255, cv2.NORM_MINMAX, cv2.CV_8U)
|
|
62
|
+
|
|
63
|
+
# iq_avg_normalized = cv2.merge([iq_avg_normalized, phase_normalized, gradient_y_normalized])
|
|
64
|
+
iq_avg_normalized = cv2.merge([iq_avg_normalized, iq_avg_normalized, iq_avg_normalized])
|
|
65
|
+
return iq_avg_normalized
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
def load_npz_to_image(file_path):
|
|
69
|
+
npz_content = load_npz_file(file_path)
|
|
70
|
+
image = convert_data_to_image(npz_content)
|
|
71
|
+
return image
|
|
72
|
+
|
|
73
|
+
def convert_spectrum_npy2npz(npy_file_path:str):
|
|
74
|
+
data = np.load(npy_file_path, allow_pickle=True)
|
|
75
|
+
data = data.item() if isinstance(data, np.ndarray) else data
|
|
76
|
+
dict_list, name_list = convert_spectrum_dict2npz(data)
|
|
77
|
+
return dict_list, name_list
|
|
78
|
+
def convert_spectrum_dict2npz(data:dict):
|
|
79
|
+
if not isinstance(data, dict) or 'image' not in data:
|
|
80
|
+
raise ValueError("数据格式无效,缺少 'image' 键")
|
|
81
|
+
image = data["image"]
|
|
82
|
+
q_list = image.keys()
|
|
83
|
+
|
|
84
|
+
dict_list = []
|
|
85
|
+
name_list = []
|
|
86
|
+
|
|
87
|
+
for idx, q_name in enumerate(q_list):
|
|
88
|
+
image_q = image[q_name]
|
|
89
|
+
|
|
90
|
+
data = image_q[0]
|
|
91
|
+
data = np.array(data)
|
|
92
|
+
data = np.abs(data)
|
|
93
|
+
height_axis = image_q[1]
|
|
94
|
+
width_axis = image_q[2]
|
|
95
|
+
new_dict = {}
|
|
96
|
+
new_dict["iq_avg"] = data
|
|
97
|
+
new_dict["frequency"] = image_q[2]
|
|
98
|
+
new_dict["bias"] = image_q[1]
|
|
99
|
+
|
|
100
|
+
npz_file_path = npy_file_path.replace(".npy", f"{q_name}.npz")
|
|
101
|
+
dict_list.append(new_dict)
|
|
102
|
+
name_list.append(npz_file_path)
|
|
103
|
+
# npz_file_path = npz_file_path.replace("npyfile","npyconverted")
|
|
104
|
+
# np.savez(npz_file_path,**new_dict)
|
|
105
|
+
# np.savez(npz_file_path,iq_avg=image_q[0],frequency=image_q[2],bias=image_q[1])
|
|
106
|
+
return dict_list, name_list
|
|
107
|
+
|
|
108
|
+
if __name__ == '__main__':
|
|
109
|
+
npy_file_path = "tmp/npyfile/tmp0ffc025b.py_4905.npy"
|
|
110
|
+
convert_spectrum_npy2npz(npy_file_path)
|
|
111
|
+
|
|
112
|
+
image = load_npz_to_image("tmp/npyconverted/tmp0ffc025b.py_4905Q6.npz")
|