Skip to content
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

Support both 3-winding and 2-winding transformers #19

Merged
merged 16 commits into from
Oct 1, 2021

Conversation

nickrobinson251
Copy link
Owner

@nickrobinson251 nickrobinson251 commented Sep 27, 2021

closes #17 (follow-up to #11)

Supports 3-winding and 2-winding transformers in the same type.

Columns not present in 2-winding data...

  • have element type Union{T, Missing}
  • are set to have value missing at parse time
  • are hidden from the users via a run-time check (in Tables.schema/Tables.columns/Tables.columnnames) of the data in the given Transformer instance

Limitations:

  • doesn't play so nice with our counting of the rows in each category to preallocate the data, for a few reasons:
    • transformer entries are split over multiple lines ...and over how many lines depends on whether the transformer is 2-winding or 3-winding... so counting is hard :suffering:
    • since they're split over multiple lines, we have to be extra careful about when a 0 indicates the end of the transformers data
  • doesn't handle those tricksy end-of-lines comments if they appear on lines 2 or 4 of the data (the lines with variable number of entries depending on if it's 2-w or 3-w)

this data is a madness

@nickrobinson251 nickrobinson251 marked this pull request as draft September 27, 2021 23:31
src/types.jl Outdated Show resolved Hide resolved
src/types.jl Outdated Show resolved Hide resolved
src/parsing.jl Outdated
for col in 1:ncols
col = 1
is_2w = false
while col < ncols
eltyp = eltype(fieldtype(typeof(rec), col))
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if using Vector{Union{T, Missing}} (rather than SentinelArray), this may need to be nonmissingtype(eltype(...))


# Store data in column table so conversion to DataFrame efficient.
Tables.istable(::Type{<:Records}) = true
Tables.columnaccess(::Type{<:Records}) = true
Tables.columns(x::Records) = x
Tables.getcolumn(x::Records, i::Int) = getfield(x, i)
Tables.columnnames(R::Type{<:Records}) = fieldnames(R)
Tables.schema(R::Type{<:Records}) = Tables.Schema(fieldnames(R), fieldtypes(R))
Tables.schema(x::R) where {R <: Records} = Tables.Schema(fieldnames(R), fieldtypes(R))
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since we have to define schema on Transformers objects (not the type itself) we define this on objects too, so we can generically call schema(x) (e.g. in show)

src/types.jl Outdated Show resolved Hide resolved
src/parsing.jl Outdated
# each "three-winding transformer" is 5 lines with (14, 11, 16, 16, 16) columns each.
const T2_COLS = (14, 3, 16, 2)
const T3_COLS = (14, 11, 16, 16, 16)
const EOL_COLS = cumsum(T3_COLS)
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i'm not sure these consts are better than magic numbers (tbh i find them harder to think about), but i suspect they might survive the test of time better...

Base automatically changed from npr/transformers to main September 30, 2021 20:59
@nickrobinson251 nickrobinson251 marked this pull request as ready for review September 30, 2021 23:43
@nickrobinson251 nickrobinson251 changed the title WIP Support 3-winding and 2-winding transformers Support both 3-winding and 2-winding transformers Sep 30, 2021
src/types.jl Outdated Show resolved Hide resolved
src/types.jl Outdated Show resolved Hide resolved
src/types.jl Outdated Show resolved Hide resolved
src/types.jl Outdated Show resolved Hide resolved
test/runtests.jl Outdated Show resolved Hide resolved
@nickrobinson251 nickrobinson251 merged commit 7893be1 into main Oct 1, 2021
@nickrobinson251 nickrobinson251 deleted the npr/3w-transformers branch October 23, 2021 10:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

How to support 2-winding and 3-winding transfomer data?
1 participant