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

Parameter improvment and some small new abilities #348

Merged
merged 18 commits into from
May 18, 2018
Merged

Conversation

tarrox
Copy link
Contributor

@tarrox tarrox commented Mar 16, 2018

  • Improvement to the current processors by adding additional parameters to set,
    primarily adding the ability to set the UnixTimeUTC key.
  • Added the ability to reverse the process for the DrsCalibration and the remapping.
  • Added a processor to combine two arrays into one by combining each element, given the four std operators.

This changes are necessary for the work I do, to make the pull easier I split the last pull request #246 up into three pull request this being the first one.

@tarrox tarrox requested review from kbruegge and maxnoe March 16, 2018 11:38
Copy link
Member

@maxnoe maxnoe left a comment

Choose a reason for hiding this comment

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

Some unneeded getters and setters

Why are "UnixTimeUTC" and "StartCellData" Parameters now? I think this is not needed and only adds fuzz.

public String badPixelKey = "badPixels";

@Parameter(required = false, description = "The key to the unixTimeUTC of the Event.")
public String unixTimeKey = "UnixTimeUTC";
Copy link
Member

Choose a reason for hiding this comment

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

Why is this a parameter?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I use this processor twice for different inputs with different times one will use 'UnixTimeUTC' the other 'LONS_UnixTimeUTC'. This is due to the fact that i have to calibrate the pedestal that I superimpose.

@@ -36,6 +36,12 @@
@Parameter(required = false, description = "The minimum number of neighboring pixels required for interpolation", defaultValue = "3")
public int minPixelToInterpolate = 3;

@Parameter(required = false, description = "The key for the resulting badPixelSet.")
public String badPixelKey = "badPixels";
Copy link
Member

Choose a reason for hiding this comment

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

Why is this an xml Parameter?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I use the processor twice, so i added this in case someone want to preserve the output and not override the key with the second processor. I think it is cleaner this way, but I can remove it.

@@ -38,6 +38,9 @@
@Parameter(required = true)
public String startCellKey = null;

@Parameter(required = false, description = "The key containing the UnixTimeUTC")
public String unixTimeKey = "UnixTimeUTC";
Copy link
Member

Choose a reason for hiding this comment

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

Why is this a parameter?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I use this processor twice for different inputs with different times one will use 'UnixTimeUTC' the other 'LONS_UnixTimeUTC'. This is due to the fact that i have to calibrate the pedestal that I superimpose.

@@ -58,6 +58,9 @@
@Service(required = false, description = "Name of the service that provides aux files")
public AuxiliaryService auxService;

@Parameter(required = false, description = "The key containing the UnixTimeUTC")
public String unixTimeKey = "UnixTimeUTC";
Copy link
Member

Choose a reason for hiding this comment

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

Why is this a Parameter?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I use this processor twice for different inputs with different times one will use 'UnixTimeUTC' the other 'LONS_UnixTimeUTC'. This is due to the fact that i have to get the sourceposition of the pedestal that I superimpose.

Copy link
Member

Choose a reason for hiding this comment

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

What is LONS supposed to mean?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

'Light of night sky' before it was PED but we already have stuff that is called pedestal so I use LONS, that way there is no conflict with the other stuff.

Copy link
Member

Choose a reason for hiding this comment

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

I'm against inventing new abbreviations that nobody uses. The commonly used abbreviation is NSB for night sky background

}


public static Logger getLog() {
Copy link
Member

Choose a reason for hiding this comment

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

Not needed

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

}


public static void setLog(Logger log) {
Copy link
Member

Choose a reason for hiding this comment

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

Not needed

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@@ -18,7 +18,11 @@
@Parameter(required = true)
public String outputKey = null;

int limitEvents = 20;
@Parameter(required = false, description = "The key containing the UnixTimeUTC")
Copy link
Member

Choose a reason for hiding this comment

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

Why is this a parameter?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For the case someone wants to set it, we have an variable in 'settings.properties' for this but no way to set it in this processor (only in the jumpRemoval). So either this one goes or, the thing in setting.properties makes little sense because it is a constant.

@maxnoe
Copy link
Member

maxnoe commented Mar 16, 2018

Please also add -SNAPSHOT to the version in the pom

@tarrox
Copy link
Contributor Author

tarrox commented Mar 16, 2018

Added the -SNAPSHOT to the version.

@tarrox tarrox mentioned this pull request Mar 16, 2018
@maxnoe
Copy link
Member

maxnoe commented Mar 16, 2018

As 1.0.1 is released now, the version for this should be 1.0.2-SNAPSHOT

Copy link
Member

@jebuss jebuss left a comment

Choose a reason for hiding this comment

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

Nice work! The UnixTimeKey stuff is ok for me. Couldyou maybe provide an example XML that is using the TimeseriesFeatures and the CombineDataArrays? If you put that to examples/studies it will run with the unit tests (?) and one can see how and why it is used. Otherwise, I would asume it would be deleted in later versions.

@maxnoe
Copy link
Member

maxnoe commented Apr 28, 2018

As we now require the timestamp key anyways, we could remove conversions from unixtimeutc to zoneddatetime and just do it once, maybe even in the readers and just use the timestamp key everywhere

@jebuss
Copy link
Member

jebuss commented Apr 30, 2018

As we now require the timestamp key anyways, we could remove conversions from unixtimeutc to zoneddatetime and just do it once, maybe even in the readers and just use the timestamp key everywhere

I'm not sure if I know what you mean. Could you point me to a file / line?

@tarrox
Copy link
Contributor Author

tarrox commented May 2, 2018

I'm not sure if I know what you mean. Could you point me to a file / line?

I think he means this neat feature here <fact.features.UnixTimeUTC2DateTime /> which does the conversation once at the beginning. This would remove the necessity to convert it be hand in every processor like in datacorrection/InterpolateTimeSeries.java:52.
I would agree with Max point that this would indeed be better but I would suggest to leave it at this for now and create a different branch where every processor gets updated to the timestamp version.

@maxnoe
Copy link
Member

maxnoe commented May 2, 2018

I'm not sure if I know what you mean. Could you point me to a file / line?

@jebuss Everywhere we do calculations involving timestamps we use ZonedDateTime. We always convert UnixTimeUTC into timestamp. We could just do this once, maybe even in the readers instead of doing it in each processor that needs to do stuff with a timestamp.

We use Utils.unixTimeUTCToZonedDatetime in these processors

src/main/java/fact/cleaning/TwoLevelTimeMedian.java
src/main/java/fact/cleaning/TwoLevelTimeNeighbor.java
src/main/java/fact/features/UnixTimeUTC2DateTime.java
src/main/java/fact/features/source/CameraToEquatorial.java
src/main/java/fact/features/source/SourcePosition.java
src/main/java/fact/datacorrection/InterpolateTimeSeries.java
src/main/java/fact/datacorrection/InterpolatePixelArray.java
src/main/java/fact/extraction/BasicExtraction.java
src/test/java/fact/io/hdureader/BinTableTests.java

@jebuss
Copy link
Member

jebuss commented May 16, 2018

Ok, @maxnoe I see your point. IMHO, it is neither a show stopper for this PR nor is there a larger clarity in opening a new issue and a new PR for this, since this PR is anyways a collection of several features. So both ways do make sense.

So I would say its up to @tarrox if he can put afford in adding the timestamp in the readers and adapt the according processors for this PR. It does not seem to be much of an afford. However, If he does not have time right now, I would also vote for opening an issue and and a new PR for this feature.

I would be happy if we could finish this PR soon.

data.put(outputKey, calibrated);
else {
short[] decalibratedShortData = new short[calibrated.length];
// System.arraycopy(rawData, 0, rawfloatData, 0, rawfloatData.length);
Copy link
Member

Choose a reason for hiding this comment

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

Commented code

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed this one and the other.


// add color value if set
//TODO add color value if set
Copy link
Member

Choose a reason for hiding this comment

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

Please just remove this line

Copy link
Contributor Author

Choose a reason for hiding this comment

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

removed

vraw /= drsGainMean[offsetPos];
vraw *= 1907.35;
triggerOffsetPos = pixel * drsTriggerOffsetMean.length / Constants.N_PIXELS
+ slice;
Copy link
Member

Choose a reason for hiding this comment

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

this line break makes things worse imho

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed this one and the other ones too


// add color value if set
//TODO add color value if set

return data;
}

public double[] applyDrsCalibration(double[] data, double[] destination,
Copy link
Member

Choose a reason for hiding this comment

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

I still think two functions would be more clear. applyDrsCalibration and revertDrsCalibration.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

split into two functions

@tarrox
Copy link
Contributor Author

tarrox commented May 16, 2018

Replaced the UnixTimeUTC with timestamp in the processors where it makes sense.

* @return The decalibrated data array
*/
public double[] reverseDrsCalibration(double[] data, double[] destination, short[] startCellVector) {
if (destination == null || destination.length != data.length)
Copy link
Member

Choose a reason for hiding this comment

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

Maybe throwing in case the length do not match is better, what do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was legacy code, but yeah i can't think of any reason where giving a different length is intentional and not an error or lazyness. Changed in the next commit.

Copy link
Member

Choose a reason for hiding this comment

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

nice


// Get variables out of data item
int[] currentTime = (int[]) item.get("UnixTimeUTC");
Copy link
Member

Choose a reason for hiding this comment

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

This processor apperently still uses UnixTimeUTC and not timestamp

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is currently intentional, this is because the previousEventInfo holds UnixTimeUTC and not timestamp, this would need to be changed. I would suggest its own PR, especially as the SamplePedestalEvent processor needs also to be changed (currently in its own branch, PR will be created once this PR is finished).

@tarrox
Copy link
Contributor Author

tarrox commented May 18, 2018

Added issue #362 for the missing unixtime->timestamp changes. So we can finish this PR quickly.

@jebuss jebuss merged commit ac9d7a4 into master May 18, 2018
@jebuss jebuss deleted the parameter_improvment branch May 18, 2018 15:28
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.

3 participants