# To regenerate the files that are based on this schema, run:
# capnp/c++/capnp compile -oc++ hit.capnp

# unique id generated by capnp.
@0xb0d6956dc23c3717; 


# The Signal contains information about a linear signal we found.
# Some of this is redundant, but it's more convenient.
struct Signal {
  # The frequency the hit starts at
  frequency @0 :Float64;

  # Which frequency bin the hit starts at
  index @1 :Int32;

  # How many bins the hit drifts over
  driftSteps @2 :Int32;

  # The drift rate in Hz/s
  driftRate @3 :Float64;

  # The signal-to-noise ratio for the hit
  snr @4 :Float32;
}

# The Filterbank contains a smaller slice of the larger filterbank that we originally
# found this hit in.
struct Filterbank {
  # These fields are like the ones found in FBH5 files.
  sourceName @0 :Text;
  fch1 @1 :Float64;
  foff @2 :Float64;
  tstart @3 :Float64;
  tsamp @4 :Float64;
  ra @5 :Float64;
  dec @6 :Float64;
  telescopeId @7 :Int32;
  numTimesteps @8 :Int32;
  numChannels @9 :Int32;

  # The length of data should be num_timesteps * num_channels.
  # Storing both of those is slightly redundant but more convenient.
  # The format is a row-major array, indexed by [timestep][channel].
  data @10 :List(Float32);
}

# A hit without a signal indicates that we looked for a hit here and didn't find one.
# A hit without a filterbank indicates that to save space we didn't store any filterbank
# data in this file; it should be available elsewhere.
struct Hit {
  signal @0 :Signal;
  filterbank @1 :Filterbank;
}
