Merge branch 'bugfix/tug_times_trouble' into release/1.1.1
This commit is contained in:
commit
3727bf266d
@ -32,7 +32,7 @@
|
|||||||
<Label Content="{x:Static p:Resources.textShip}" Grid.Column="0" Grid.Row="0" HorizontalContentAlignment="Right"/>
|
<Label Content="{x:Static p:Resources.textShip}" Grid.Column="0" Grid.Row="0" HorizontalContentAlignment="Right"/>
|
||||||
<ComboBox x:Name="comboBoxShip" Margin="2" Grid.Column="1" Grid.Row="0" SelectionChanged="comboBoxShip_SelectionChanged" SelectedValuePath="Ship.Id" IsEditable="True" IsTextSearchEnabled="True" IsTextSearchCaseSensitive="False" />
|
<ComboBox x:Name="comboBoxShip" Margin="2" Grid.Column="1" Grid.Row="0" SelectionChanged="comboBoxShip_SelectionChanged" SelectedValuePath="Ship.Id" IsEditable="True" IsTextSearchEnabled="True" IsTextSearchCaseSensitive="False" />
|
||||||
<Label Content="IMO" Grid.Column="0" Grid.Row="1" HorizontalContentAlignment="Right"/>
|
<Label Content="IMO" Grid.Column="0" Grid.Row="1" HorizontalContentAlignment="Right"/>
|
||||||
<xctk:IntegerUpDown x:Name="integerUpDownIMO" IsReadOnly="True" Margin="2" Grid.Column="1" Grid.Row="1" />
|
<xctk:IntegerUpDown x:Name="integerUpDownIMO" IsReadOnly="True" Margin="2" Grid.Column="1" Grid.Row="1" ShowButtonSpinner="False"/>
|
||||||
<Label Content="{x:Static p:Resources.textCallsign}" Grid.Column="0" Grid.Row="2" HorizontalContentAlignment="Right"/>
|
<Label Content="{x:Static p:Resources.textCallsign}" Grid.Column="0" Grid.Row="2" HorizontalContentAlignment="Right"/>
|
||||||
<TextBox x:Name="textBoxCallsign" IsReadOnly="True" Grid.Column="1" Grid.Row="2" Margin="2" />
|
<TextBox x:Name="textBoxCallsign" IsReadOnly="True" Grid.Column="1" Grid.Row="2" Margin="2" />
|
||||||
<Label Content="{x:Static p:Resources.textLength}" Grid.Column="0" Grid.Row="3" HorizontalContentAlignment="Right"/>
|
<Label Content="{x:Static p:Resources.textLength}" Grid.Column="0" Grid.Row="3" HorizontalContentAlignment="Right"/>
|
||||||
|
|||||||
@ -134,8 +134,16 @@ class ValidationRuleBaseFunctions():
|
|||||||
participant_types = [ParticipantType.AGENCY.value, ParticipantType.MOORING.value, ParticipantType.PORT_ADMINISTRATION.value, ParticipantType.PILOT.value, ParticipantType.TUG.value]
|
participant_types = [ParticipantType.AGENCY.value, ParticipantType.MOORING.value, ParticipantType.PORT_ADMINISTRATION.value, ParticipantType.PILOT.value, ParticipantType.TUG.value]
|
||||||
else:
|
else:
|
||||||
participant_types = [ParticipantType.AGENCY.value, ParticipantType.MOORING.value, ParticipantType.PILOT.value, ParticipantType.TUG.value]
|
participant_types = [ParticipantType.AGENCY.value, ParticipantType.MOORING.value, ParticipantType.PILOT.value, ParticipantType.TUG.value]
|
||||||
|
|
||||||
|
agency_times = df_times.loc[df_times["participant_type"]==ParticipantType.AGENCY.value,:]
|
||||||
df_times = df_times.loc[df_times["participant_type"].isin(participant_types),:]
|
df_times = df_times.loc[df_times["participant_type"].isin(participant_types),:]
|
||||||
|
|
||||||
|
|
||||||
|
agency_time = [time_ for time_ in agency_times.loc[:,query].tolist() if isinstance(time_, pd.Timestamp)]
|
||||||
|
if not len(agency_time):
|
||||||
|
violation_state = False
|
||||||
|
return violation_state
|
||||||
|
|
||||||
# exclude missing entries and consider only pd.Timestamp entries (which ignores pd.NaT/null entries)
|
# exclude missing entries and consider only pd.Timestamp entries (which ignores pd.NaT/null entries)
|
||||||
estimated_times = [time_ for time_ in df_times.loc[:,query].tolist() if isinstance(time_, pd.Timestamp)] # df_times = df_times.loc[~df_times[query].isnull(),:]
|
estimated_times = [time_ for time_ in df_times.loc[:,query].tolist() if isinstance(time_, pd.Timestamp)] # df_times = df_times.loc[~df_times[query].isnull(),:]
|
||||||
|
|
||||||
@ -144,8 +152,17 @@ class ValidationRuleBaseFunctions():
|
|||||||
violation_state = False
|
violation_state = False
|
||||||
return violation_state
|
return violation_state
|
||||||
|
|
||||||
difference = np.max(estimated_times) - np.min(estimated_times)
|
# this (current) solution compares times to the reference (agency) time and checks if the difference is greater than 15 minutes
|
||||||
violation_state = difference > pd.Timedelta("15min")
|
violation_state = ((np.max(estimated_times) - agency_time[0]) > pd.Timedelta("15min")) or ((agency_time[0] - np.min(estimated_times)) > pd.Timedelta("15min"))
|
||||||
|
|
||||||
|
# this solution to the rule compares all times to each other. When there is a total difference of more than 15 minutes, a violation occurs
|
||||||
|
# Consequently, it treats all times as equally important
|
||||||
|
# difference = np.max(estimated_times) - np.min(estimated_times)
|
||||||
|
# violation_state = difference > pd.Timedelta("15min")
|
||||||
|
|
||||||
|
# this solution clamps the times to 15 minute intervals and compares these values. When there is a single time difference, a violation occurs
|
||||||
|
# the drawback is that in some cases if there is a minimal difference say of 1 minute (:22 and :23 minutes after the hour) the violation is
|
||||||
|
# triggered even though the times are very close to each other
|
||||||
|
|
||||||
# apply rounding. For example, the agreement of different participants may be required to match minute-wise
|
# apply rounding. For example, the agreement of different participants may be required to match minute-wise
|
||||||
# '15min' rounds to 'every 15 minutes'. E.g., '2023-09-22 08:18:49' becomes '2023-09-22 08:15:00'
|
# '15min' rounds to 'every 15 minutes'. E.g., '2023-09-22 08:18:49' becomes '2023-09-22 08:15:00'
|
||||||
@ -156,6 +173,8 @@ class ValidationRuleBaseFunctions():
|
|||||||
# times_agency.eta_berth==times_mooring.eta_berth==times_portadministration.eta_berth==times_pilot.eta_berth==times_tug.eta_berth
|
# times_agency.eta_berth==times_mooring.eta_berth==times_portadministration.eta_berth==times_pilot.eta_berth==times_tug.eta_berth
|
||||||
# n_unique_times = len(np.unique(estimated_times))
|
# n_unique_times = len(np.unique(estimated_times))
|
||||||
# violation_state = n_unique_times!=1
|
# violation_state = n_unique_times!=1
|
||||||
|
|
||||||
|
|
||||||
return violation_state
|
return violation_state
|
||||||
|
|
||||||
def check_unique_shipcall_counts(self, query:str, times_agency:pd.DataFrame, rounding="min", maximum_threshold=3, all_times_agency=None)->bool:
|
def check_unique_shipcall_counts(self, query:str, times_agency:pd.DataFrame, rounding="min", maximum_threshold=3, all_times_agency=None)->bool:
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user