2525
2626# Configura el nivel de registro para GeoPandas y Fiona
2727logging .getLogger ("geopandas" ).setLevel (logging .ERROR )
28- logging .getLogger ("fiona" ).setLevel (logging .ERROR )
2928
3029logger = logging .getLogger (os .path .basename (__file__ ))
3130
@@ -319,6 +318,7 @@ def taxonomic_percentajes(df):
319318 / total_data
320319 * 100
321320 )
321+
322322 except Exception as e :
323323 logger .debug (f"ERROR genus - { e } " )
324324 percentaje_genus = 0
@@ -364,10 +364,10 @@ def taxonomic_percentajes(df):
364364
365365 return {
366366 "Taxonomic" : percentaje_taxonomic ,
367- "Genus" : percentaje_genus ,
368- "Species" : percentaje_species ,
369- "Hierarchy" : percentaje_hierarchy ,
370- "Identifiers" : percentaje_identifiers ,
367+ "Genus" : 0.2 * percentaje_genus ,
368+ "Species" : 0.1 * percentaje_species ,
369+ "Hierarchy" : 0.09 * percentaje_hierarchy ,
370+ "Identifiers" : 0.06 * percentaje_identifiers ,
371371 }
372372
373373
@@ -400,10 +400,9 @@ def geographic_percentajes(df):
400400 {'Geographic': 63.45, 'Coordinates': 25.6, 'Countries': 15.2, 'CoordinatesUncertainty': 18.9, 'IncorrectCoordinates': 3.75}
401401 """
402402 try :
403- __BD_BORDERS = gpd .read_file (gpd . datasets . get_path ( "naturalearth_lowres" ) )
403+ __BD_BORDERS = gpd .read_file ("static/ne_110m_admin_0_countries.shp" )
404404 # Total de ocurrencias
405405 total_data = len (df )
406-
407406 # Porcentaje de ocurrencias con coordenadas válidas (latitud y longitud presentes)
408407 percentaje_coordinates = (
409408 len (df [df ["decimalLatitude" ].notnull () & df ["decimalLongitude" ].notnull ()])
@@ -427,6 +426,7 @@ def geographic_percentajes(df):
427426 / total_data
428427 * 100
429428 )
429+
430430 except Exception as e :
431431 logger .debug (f"ERROR countries - { e } " )
432432 percentaje_countries = 0
@@ -454,6 +454,7 @@ def geographic_percentajes(df):
454454 / total_data
455455 * 100
456456 )
457+
457458 except Exception as e :
458459 logger .debug (f"ERROR incorrect coordinates - { e } " )
459460 percentaje_incorrect_coordinates = 0
@@ -470,10 +471,10 @@ def geographic_percentajes(df):
470471 logging .error (e )
471472 return {
472473 "Geographic" : percentaje_geographic ,
473- "Coordinates" : percentaje_coordinates ,
474- "Countries" : percentaje_countries ,
475- "CoordinatesUncertainty" : percentaje_coordinates_uncertainty ,
476- "IncorrectCoordinates" : percentaje_incorrect_coordinates ,
474+ "Coordinates" : 0.2 * percentaje_coordinates ,
475+ "Countries" : 0.1 * percentaje_countries ,
476+ "CoordinatesUncertainty" : 0.05 * percentaje_coordinates_uncertainty ,
477+ "IncorrectCoordinates" : - 0.2 * percentaje_incorrect_coordinates ,
477478 }
478479
479480
@@ -518,7 +519,13 @@ def safe_date(date):
518519 # Columna de fechas
519520 dates = df [df .eventDate .notnull ()].copy ()
520521 if dates .empty :
521- return {"Temporal" : 0 , "Years" : 0 , "Months" : 0 , "Days" : 0 , "IncorrectDates" : 0 }
522+ return {
523+ "Temporal" : - 15 / 0.2 ,
524+ "Years" : 0 ,
525+ "Months" : 0 ,
526+ "Days" : 0 ,
527+ "IncorrectDates" : - 15 ,
528+ }
522529 dates ["date" ] = dates .eventDate .apply (safe_date )
523530
524531 # Porcentaje de años validos
@@ -573,10 +580,10 @@ def safe_date(date):
573580
574581 return {
575582 "Temporal" : percentaje_temporal ,
576- "Years" : percentaje_years ,
577- "Months" : percentaje_months ,
578- "Days" : percentaje_days ,
579- "IncorrectDates" : percentaje_incorrect_dates ,
583+ "Years" : 0.11 * percentaje_years ,
584+ "Months" : 0.07 * percentaje_months ,
585+ "Days" : 0.02 * percentaje_days ,
586+ "IncorrectDates" : 0.15 * percentaje_incorrect_dates ,
580587 }
581588
582589
0 commit comments