-
Notifications
You must be signed in to change notification settings - Fork 17
Implement the classes Imo and ImoFlatFile #33
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
Conversation
This PR adds two classes to the framework: 1. `Imo` is an abstract class 2. `ImoFlatFile` is a concrete class that provides methods to read the IMO from a YAML file, much like the one created by `instrumentdb` (https://github.com/ziotom78/instrumentdb)
|
Thanks Maurizio for this. I had a look at the |
Several changes:
- Composition is now used instead of inheritance, so that
ImoFlatFile is no longer a descendant of Imo
- Public API to remote IMO is enabled (see Imo.__init__)
- The classes FormatSpecification, Entity, Quantity, DataFile,
and Release have been moved to a separate file
- Tests are more comprehensive
- Additional way to refer to a release: "/release/TAG/..."
instead of only "/TAG/..." (this is more compliant with the
IMO specification)
- Export JSON over YAML for the flat-file schema, according to
ziotom78/instrumentdb#26
|
As we discussed previously, I’m willing to help with the integration of the temporary imo into the litebrid_dim. Is it still relevant? Where can I find the codes and/or data we have to interface? |
|
Hi @dpole , the repository is here but it's private: https://github.com/litebird/litebird_imo. You should request access to @paganol (BTW, can you please add me too, Luca?) Something we should do ASAP is to fix the key names used in the metadata, so that measurement units are always indicated. For instance, replace Another thing to check is the presence of multiple "data files" for each quantity. I made a quick check, and it seems that the current database is large also because there are many older versions of data files saved. Our first internal release of |
|
About access, it should be private only for the outside world and not for people in the litebird organization. I just tested that I'm able to checkout and push. Let me know if you have limitations instead. |
Oh, that's great, I didn't have time to create a PR for it, so I did not check… |
This imports the work done to add code information to the report, so that it can be completed with information about the IMO.
|
Hi @ziotom78, having more examples on how to retrieve information from the IMO flat file would be great! for example, how can I get the specifications (like sensitivity and resolution) for all the LB channels? |
|
Hi @ziotom78, related to @NicolettaK's question, do we need to assign a release version to every data_file, in order to be able to read them using the full path? it seems so. The mock_imo works for /releases/1.0/focal_plane/beams/horn01/horn01_grasp, but then it does not for the others. |
This commit removes the lines of code that raised an exception whenever one of the folders "data_files", "format_spec" or "plot_files" was missing in a flat-file representation of the IMO. The matter is, these folders can be missing if there are no data files, no format specifications, or no plot files, and that is perfectly fine.
…tebird_imo v0.10 and instrumentdb v0.4.0
As it is now, you can access a data file that is not part of a data release only through its UUID. I believe this is fair, as we want people to be really sure of what they're doing when they are not using official IMO parameters. |
The fields of the class now match the field names used in litebird_imo. New tests have been added to ensure that detectors can be read properly from the IMO.
|
Ok, I believe the PR is complete now. I have made modifications to the Reading detectors from the IMO is easy: imo = lbs.Imo(...)
uuid = UUID("78fe75f1-a011-44b6-86dd-445dc9634416")
det = lbs.read_detector_from_imo(imo, uuid)
print(det)If one wants to simulate a custom detector, its definition can be read from a TOML file (e.g., a parameter file specified by the user running the script): import litebird_sim as lbs, tomlkit
doc = tomlkit.parse("""
[my_detector]
name = "foo"
wafer = "bar"
pixel = "abc"
pixtype = "def"
channel = "ghi"
sampling_rate_hz = 12.0
fwhm_arcmin = 34.0
ellipticity = 56.0
net_ukrts = 78.0
fknee_mhz = 90.0
fmin_hz = 98.0
alpha = 76.0
pol = "jkl"
orient = "mno"
quat = [0.0, 1.0, 2.0, 3.0]
""")
det = lbs.read_detector_from_dict(doc["my_detector"])
print(det)(Of course, it's trivial to adapt this latter example to read the definition from a JSON/YAML/... file.) |
|
I just want to point out a couple of thing in #42 that we may want to coordinate with this PR. In #42 I removed the I was not sure about how to choose the detector fields to be loaded from the IMO. For time being I'm using a mock code that receives the litebird_sim/litebird_sim/observations.py Line 67 in e7f764c
|
I believe it's important to have a I'm not sure how your line of code above using |
This PR adds two classes to the framework:
Imois an abstract classImoFlatFileis a concrete class that provides methods to read the IMO from a YAML file, much like the one created byinstrumentdb(https://github.com/ziotom78/instrumentdb)Examples of use are in file tests/test_imo.py. They are like the following:
Things to do:
ImoFlatFileSimulationobjectsI would like to wait for comments before writing the documentation.