@@ -612,13 +612,9 @@ def __init__(self):
612612 super (LoadRaster , self ).__init__ ()
613613 self .call_funct = LOADRASTER
614614
615- # R0913:326: Too many arguments (9/6)
616- # pylint: disable=R0913
617- def __call__ (self , context , attribute_label ,
615+ def __call__ (self , context , attribute_label , file_list ,
618616 clip_exposure2all_hazards = False ,
619- file_list = None , file_format = None , variable = None ,
620- raster = None , upper_left_x = None , upper_left_y = None ,
621- cell_size = None , no_data_value = None ):
617+ file_format = None , variable = None , no_data_value = None ):
622618 """
623619 Load one or more files and get the value for all the
624620 exposure points. All files have to be of the same attribute.
@@ -628,79 +624,45 @@ def __call__(self, context, attribute_label,
628624 :param attribute_label: The string to be associated with this data.
629625 :param clip_exposure2all_hazards: True if the exposure data is
630626 clippped to the hazard data, so no hazard values are ignored.
631-
632627 :param file_list: A list of files or a single file to be loaded.
633- OR
634- :param raster: A 2D numeric array of the raster values, North is up.
635- :param upper_left_x: The longitude at the upper left corner.
636- :param upper_left_y: The latitude at the upper left corner.
637- :param cell_size: The cell size.
638628 :param no_data_value: Values in the raster that represent no data.
639629
640-
641630 Context return:
642631 exposure_att: Add the file values into this dictionary.
643632 key: column titles
644633 value: column values, except the title
645634 """
646635
647- # We need a file or a full set of raster info.
648- if file_list is None :
649- # The raster info is being passed as an array
650- assert raster is not None
651- assert upper_left_x is not None
652- assert upper_left_y is not None
653- assert cell_size is not None
654- assert no_data_value is not None
655- a_raster = raster_module .Raster .from_array (
656- raster , upper_left_x ,
657- upper_left_y ,
658- cell_size ,
659- no_data_value )
660-
661- if clip_exposure2all_hazards :
662- # Reduce the context to the hazard area
663- # before the raster info has been added to the context
664- extent = a_raster .extent ()
665- context .clip_exposure (* extent )
666-
667- file_data = a_raster .raster_data_at_points (
668- context .exposure_long ,
669- context .exposure_lat )
670- file_data = np .where (file_data == no_data_value , np .NAN ,
671- file_data )
672- context .exposure_att [attribute_label ] = file_data
673- else :
674- if isinstance (file_list , str ):
675- file_list = [file_list ]
676-
677- for f in file_list :
678- f = misc .download_file_from_s3_if_needed (f )
679- dt = misc .get_file_mtime (f )
680- atts = {"dcterms:title" : "Source hazard data" ,
681- "prov:type" : "prov:Dataset" ,
682- "prov:atLocation" : os .path .basename (f ),
683- "prov:format" : os .path .splitext (f )[1 ].replace ('.' , '' ),
684- "prov:generatedAtTime" : dt , }
685- if file_format == 'nc' and variable :
686- atts ['prov:variable' ] = variable
687- hazent = context .prov .entity (":Hazard data" , atts )
688- context .prov .used (context .provlabel , hazent )
636+ if isinstance (file_list , str ):
637+ file_list = [file_list ]
689638
639+ for f in file_list :
640+ f = misc .download_file_from_s3_if_needed (f )
641+ dt = misc .get_file_mtime (f )
642+ atts = {"dcterms:title" : "Source hazard data" ,
643+ "prov:type" : "prov:Dataset" ,
644+ "prov:atLocation" : os .path .basename (f ),
645+ "prov:format" : os .path .splitext (f )[1 ].replace ('.' , '' ),
646+ "prov:generatedAtTime" : dt , }
690647 if file_format == 'nc' and variable :
691- file_list = misc .mod_file_list (file_list , variable )
648+ atts ['prov:variable' ] = variable
649+ hazent = context .prov .entity (":Hazard data" , atts )
650+ context .prov .used (context .provlabel , hazent )
651+
652+ if file_format == 'nc' and variable :
653+ file_list = misc .mod_file_list (file_list , variable )
692654
693- file_data , extent = raster_module .files_raster_data_at_points (
694- context .exposure_long ,
695- context .exposure_lat , file_list )
696- file_data [file_data == no_data_value ] = np .NAN
655+ file_data , extent = raster_module .files_raster_data_at_points (
656+ context .exposure_long ,
657+ context .exposure_lat , file_list )
658+ file_data [file_data == no_data_value ] = np .NAN
697659
698- context .exposure_att [attribute_label ] = file_data
660+ context .exposure_att [attribute_label ] = file_data
699661
700- if clip_exposure2all_hazards :
701- # Clipping the exposure points after the data has been added.
702- # Not optimised for speed, but easy to implement.
703- context .clip_exposure (* extent )
662+ if clip_exposure2all_hazards :
663+ # Clipping the exposure points after the data has been added.
664+ # Not optimised for speed, but easy to implement.
665+ context .clip_exposure (* extent )
704666
705667
706668class AggregateLoss (Job ):
0 commit comments