def write_raster_window(<EOL>in_tile=None, in_data=None, out_profile=None, out_tile=None, out_path=None,<EOL>tags=None, bucket_resource=None<EOL>):
if not isinstance(out_path, str):<EOL><INDENT>raise TypeError("<STR_LIT>")<EOL><DEDENT>logger.debug("<STR_LIT>", out_path)<EOL>if out_path == "<STR_LIT>":<EOL><INDENT>raise DeprecationWarning(<EOL>"<STR_LIT>"<EOL>"<STR_LIT>"<EOL>)<EOL><DEDENT>out_tile = in_tile if out_tile is None else out_tile<EOL>_validate_write_window_params(in_tile, out_tile, in_data, out_profile)<EOL>window_data = extract_from_array(<EOL>in_raster=in_data,<EOL>in_affine=in_tile.affine,<EOL>out_tile=out_tile<EOL>) if in_tile != out_tile else in_data<EOL>if "<STR_LIT>" in out_profile:<EOL><INDENT>out_profile["<STR_LIT>"] = out_profile.pop("<STR_LIT>")<EOL><DEDENT>if window_data.all() is not ma.masked:<EOL><INDENT>try:<EOL><INDENT>if out_path.startswith("<STR_LIT>"):<EOL><INDENT>with RasterWindowMemoryFile(<EOL>in_tile=out_tile,<EOL>in_data=window_data,<EOL>out_profile=out_profile,<EOL>out_tile=out_tile,<EOL>tags=tags<EOL>) as memfile:<EOL><INDENT>logger.debug((out_tile.id, "<STR_LIT>", out_path))<EOL>bucket_resource.put_object(<EOL>Key="<STR_LIT:/>".join(out_path.split("<STR_LIT:/>")[<NUM_LIT:3>:]),<EOL>Body=memfile<EOL>)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>with rasterio.open(out_path, '<STR_LIT:w>', **out_profile) as dst:<EOL><INDENT>logger.debug((out_tile.id, "<STR_LIT>", out_path))<EOL>dst.write(window_data.astype(out_profile["<STR_LIT>"], copy=False))<EOL>_write_tags(dst, tags)<EOL><DEDENT><DEDENT><DEDENT>except Exception as e:<EOL><INDENT>logger.exception("<STR_LIT>", out_path, e)<EOL>raise<EOL><DEDENT><DEDENT>else:<EOL><INDENT>logger.debug((out_tile.id, "<STR_LIT>", out_path))<EOL><DEDENT>
Write a window from a numpy array to an output file.

Parameters
----------
in_tile : ``BufferedTile``
    ``BufferedTile`` with a data attribute holding NumPy data
in_data : array
out_profile : dictionary
    metadata dictionary for rasterio
out_tile : ``Tile``
    provides output boundaries; if None, in_tile is used
out_path : string
    output path to write to
tags : optional tags to be added to GeoTIFF file
bucket_resource : boto3 bucket resource to write to in case of S3 output