Comments (5)
It looks like the only use of catalog_traces()
is in reader.py
, and it doesn't make any attempt to account for None
values coming out of catalog_traces()
. The only place where a None
check is made is when we calculate dimensionality right after calling catalog_traces()
. In every other place where the catalogs are referenced, we assume that they're Mapping
references.
From what I can see, we can safely replace these None
s with empty dicts. That is, when reader.py
sees None
come out of catalog_traces()
, it could replace these with {}
. It looks like that's really what reader.py
expects anyway.
We might even be able to go a step further and have catalog_traces()
return {}
instead of None
. But I'm not sure right now if catalog_traces()
can return {}
already and, if so, if that's semantically different from None
.
from segpy.
As a first experiment (and to temporarily shave this yak so I can do testing), I'm going to turn None
s into empty dicts in reader.py
.
from segpy.
If I remember correctly, you can get None
s in the case that there is no bijective mapping, for example if there are duplicate keys. This shouldn't happen with well-formed SEG-Y, but it does. The CatalogBuilder.create()
method returns None
if there are duplicates.
I think an "empty" SEG-Y file containing headers but zero traces could legitimately have empty dictionaries.
from segpy.
Looking at this again, the intent is that clients should not usually construct SegYReader2D
directly, and should prefer to go via create_reader()
. There's a comment to this effect in the docstring for SegYReader2D.__init__()
where it says, "Usually a SegYReader is most easily constructed using the create_reader() function", although this should be more strongly worded.
The logic in _make_reader()
which tries to determine the dimensionality of the SEG-Y assumes that, the the case the caller of create_reader()
has left dimensionality
at the default value of None
, that a cdp_catalog
is successfully constructed, and so cdp_catalog
is not None
.
Given this, I think it's entirely reasonable that SegYReader2D.__init__()
raises a TypeError
if its cdp_cataclog
argument is None
(or better, if it is not a mapping. There's possibly also a length check we could make here to ensure the various mappings have consistent lengths).
Essentially, if you can't provide a valid cdp_catalog
mapping you're not in a position to use SegYReader2D
anyway, so you need to fall back to using plain-old SegYReader
.
Similarly, SegYReader3D.__init__()
should raise a TypeError
if its line_catalog
argument is not a mapping. The SegYReader
base class should sanity check its various arguments in SegYReader.__init__()
. These checks weren't initially included because of the assumption that callers would go via create_reader()
, but that's definitely one assumption too far.
It's much better if these objects establish their class invariants in their initialisers that having to accommodate testing for various non-sensical states once they've been constructed.
from segpy.
Should we go ahead and close this? I think so, but could use a second opinion.
from segpy.
Related Issues (20)
- Fix invalid license change in `segpy-lite` HOT 4
- `header()` strategy produces unusable binary reel headers HOT 11
- Investigate using AFL to generate SEG-Y files for testing
- Sporadic health-check failures for `test_regular_mapping` HOT 1
- Small error in segpy-numpy
- Confusion about dimensionality detection heuristic HOT 3
- Python <= 3.4 compatibility
- Use plugins and named extensions for trace headers HOT 3
- segy 3d read error HOT 12
- Use our exit-codes modules for exit codes
- how to get data HOT 3
- How to read latitude/longitude or xcoordinate/ycoordinate information?? HOT 17
- Unable to read shot_gather.sgy file with error: ValueError: Assigned value 43690 for num_samples HOT 1
- How to process the massive data? HOT 1
- How to read minimum and maximum values of time (ms) from .sgy files using segpy or any other seismic reader library?
- Read illegal trace lengths? HOT 5
- cannot get the trace header HOT 1
- Mapping, Sequence and Iterable are not referenced
- TraceHeaderRev0 is not compatible with CatalogSubFormat
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from segpy.