Skip to content

Commit

Permalink
Add getall keyword argument
Browse files Browse the repository at this point in the history
  • Loading branch information
garrekstemo committed Jun 25, 2022
1 parent 090d4b5 commit a9fff7d
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 13 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name = "LVM"
uuid = "76785837-0c5d-45c2-90b8-8e8ea9f9a99d"
authors = ["Garrek Stemo <8449000+garrekds@users.noreply.github.com>"]
version = "0.1.4"
version = "0.1.5"
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,19 @@ This becomes

```
Dict(:A => [0.1, 0.2, 0.3, 0.2, 0.1], :B => [...], :C => [...], :D => [...], :E => [...])
```

## Example of how to use `LVM.read`

If anyone besides me is using this, then they should pass `getall=true` in the arguments.
Otherwise, it will look for keywords in the headers specific to my experiment and change the
corresponding dictionary keys to be more readable.

```
julia> LVM.read(filename, getall=true)
Dict{Any, Any}:
"CH0" => [...]
"CH1" => [...]
...
```
29 changes: 17 additions & 12 deletions src/LVM.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module LVM

function read(file::String)
function read(file::String; getall::Bool=false)

headerindex = Int[]
headers = []
Expand Down Expand Up @@ -41,23 +41,28 @@ function read(file::String)

for (k, header) in enumerate(headers[i])

if occursin("wavelength", header)
data["wavelength"] = chunk[:, k]
end
if occursin("wavenum", header)
data["wavenumber"] = chunk[:, k]
end
if getall == true
data[header] = chunk[:, k]
else
if occursin("wavelength", header)
data["wavelength"] = chunk[:, k]
end
if occursin("wavenum", header)
data["wavenumber"] = chunk[:, k]
end

if occursin("CH0_diff", header)
data["diffsignal"] = chunk[:, k]
elseif occursin("CH0_", header)
data["signal"] = chunk[:, k]
if occursin("CH0_diff", header)
data["diffsignal"] = chunk[:, k]
elseif occursin("CH0_", header)
data["signal"] = chunk[:, k]
end
end
end

end
end

return data
end


end # module

0 comments on commit a9fff7d

Please sign in to comment.