Skip to content

Commit b9e24c4

Browse files
committed
Remove source params and add name
1 parent 938b127 commit b9e24c4

File tree

3 files changed

+4
-52
lines changed

3 files changed

+4
-52
lines changed

src/scippneutron/metadata/__init__.py

-16
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,6 @@
2424
RadiationProbe
2525
SourceType
2626
27-
.. rubric:: Domain Types
28-
29-
.. autosummary::
30-
:toctree: ../classes
31-
:template: model-template.rst
32-
33-
PulseDuration
34-
SourceFrequency
35-
SourcePeriod
36-
3727
.. rubric:: Attributes
3828
3929
.. autosummary::
@@ -47,9 +37,6 @@
4737
Software,
4838
Source,
4939
Measurement,
50-
PulseDuration,
51-
SourceFrequency,
52-
SourcePeriod,
5340
SourceType,
5441
ESS_SOURCE,
5542
RadiationProbe,
@@ -63,9 +50,6 @@
6350
'ORCIDiD',
6451
'Software',
6552
'Source',
66-
'PulseDuration',
67-
'SourceFrequency',
68-
'SourcePeriod',
6953
'SourceType',
7054
'ESS_SOURCE',
7155
'RadiationProbe',

src/scippneutron/metadata/_model.py

+4-34
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,10 @@
44

55
import enum
66
from datetime import datetime
7-
from typing import NewType
87

9-
import scipp as sc
108
import scippnexus as snx
119
from dateutil.parser import parse as parse_datetime
12-
from pydantic import BaseModel, ConfigDict, EmailStr
10+
from pydantic import BaseModel, EmailStr
1311

1412
from ._orcid import ORCIDiD
1513

@@ -292,14 +290,6 @@ def _deduce_package_source_url(package_name: str) -> str | None:
292290
return None
293291

294292

295-
PulseDuration = NewType('PulseDuration', sc.Variable)
296-
PulseDuration.__doc__ = """Duration of a source pulse."""
297-
SourceFrequency = NewType('SourceFrequency', sc.Variable)
298-
SourceFrequency.__doc__ = """Frequency of a source pulse."""
299-
SourcePeriod = NewType('SourcePeriod', sc.Variable)
300-
SourcePeriod.__doc__ = """Period of a source pulse."""
301-
302-
303293
class SourceType(str, enum.Enum):
304294
"""Type of source.
305295
@@ -327,36 +317,16 @@ class Source(BaseModel):
327317
The ESS source is provided as ``scippneutron.metadata.ESS_SOURCE``.
328318
"""
329319

330-
# Needed to allow Scipp objects
331-
model_config = ConfigDict(arbitrary_types_allowed=True)
332-
333-
frequency: SourceFrequency
334-
"""The source frequency in Hz."""
335-
pulse_duration: PulseDuration
336-
"""The pulse duration in s."""
337-
320+
name: str | None = None
321+
"""Name of the source."""
338322
source_type: SourceType
339323
"""Type of this source."""
340324
probe: RadiationProbe
341325
"""Radiation probe of the source."""
342326

343-
@property
344-
def period(self) -> SourcePeriod:
345-
"""The source period in ns."""
346-
return SourcePeriod((1 / self.frequency).to(unit='ns'))
347-
348-
def to_pipeline_params(self) -> dict[type, object]:
349-
"""Package the physical source parameters for a Sciline pipeline."""
350-
return {
351-
PulseDuration: self.pulse_duration,
352-
SourceFrequency: self.frequency,
353-
SourcePeriod: self.period,
354-
}
355-
356327

357328
ESS_SOURCE = Source(
358-
frequency=SourceFrequency(sc.scalar(14.0, unit='Hz')),
359-
pulse_duration=PulseDuration(sc.scalar(0.003, unit='s')),
329+
name="ESS Butterfly",
360330
source_type=SourceType.SpallationNeutronSource,
361331
probe=RadiationProbe.Neutron,
362332
)

tests/io/cif_test.py

-2
Original file line numberDiff line numberDiff line change
@@ -925,8 +925,6 @@ def test_builder_with_beamline_and_source() -> None:
925925
cif_ = original.with_beamline(
926926
metadata.Beamline(name='Balder', facility='MAX IV'),
927927
metadata.Source(
928-
frequency=metadata.SourceFrequency(sc.scalar(0)),
929-
pulse_duration=metadata.PulseDuration(sc.scalar(0)),
930928
source_type=metadata.SourceType.SynchrotronXraySource,
931929
probe=metadata.RadiationProbe.Xray,
932930
),

0 commit comments

Comments
 (0)