title: Calling a function from an external file in Python
body: <p>Im trying to call a function from a different file in python. Im trying to process satellite images from Goes 16 in NetCDF format. Im extracting different values from the file necessary for the functions saved in a .py file called "remap". A piece of my main code goes like this:</p>
  
  <pre><code>from remap import remap
  # Calculate the image extent required for the reprojection
  H = nc.variables['goes_imager_projection'].perspective_point_height
  x1 = nc.variables['x_image_bounds'][0] * H
  x2 = nc.variables['x_image_bounds'][1] * H
  y1 = nc.variables['y_image_bounds'][1] * H
  y2 = nc.variables['y_image_bounds'][0] * H
  
  # Projection Prameters 
  lat_0 = nc.variables['goes_imager_projection'].latitude_of_projection_origin
  lon_0 = nc.variables['goes_imager_projection'].longitude_of_projection_origin
  a = nc.variables['goes_imager_projection'].semi_major_axis
  b = nc.variables['goes_imager_projection'].semi_minor_axis
  f = 1/nc.variables['goes_imager_projection'].inverse_flattening
  
  # Call the reprojection funcion
  grid = remap(path, extent, resolution, x1, y1, x2, y2)
  </code></pre>
  
  <p>In the .py file that I called "remap", the function is defined as:</p>
  
  <pre><code># Define KM_PER_DEGREE
  KM_PER_DEGREE = 111.32
  
  # GOES-16 Spatial Reference System
  sourcePrj = osr.SpatialReference()
  sourcePrj.ImportFromProj4('+proj=geos +h=' + H + ' +a=' + a + ' +b=' + b + '  +f=' + f + 'lat_0=' + lat_0 + ' +lon_0=' + lon_0 + ' +sweep=x +no_defs')
  
  # Lat/lon WSG84 Spatial Reference System
  targetPrj = osr.SpatialReference()
  targetPrj.ImportFromProj4('+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs')
  
  def remap(path, extent, resolution, x1, y1, x2, y2):
  ... (and so on)
  </code></pre>
  
  <p>Now I have two different problems:</p>
  
  <p>(1) My frist problem is that Im getting an error from the system saying:
  "remap() takes 4 positional arguments but 7 were given", which I dont understand why is happening, because I already defined those 7 arguments in the function from the second file called "remap"</p>
  
  <p>(2) My second problem is that I don't know how to call values from my original code that where extracted from the NetCDF file such as: "lat_0, lon_0, a, b, f, and H" to be used in the second file which are necessary from the beginning to used the function "remap".</p>
  
  <p>Any suggestions?</p>