Skip to content

Commit b5a178a

Browse files
committed
linting
1 parent 877dc8c commit b5a178a

3 files changed

Lines changed: 23 additions & 17 deletions

File tree

uvdat/core/rest/map_layers.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
import json
22
import logging
33

4+
from django.contrib.contenttypes.models import ContentType
45
from django.contrib.gis.db.models import Extent
56
from django.db import connection
67
from django.http import HttpResponse, JsonResponse
78
from django_large_image.rest import LargeImageFileDetailMixin
8-
from django.contrib.contenttypes.models import ContentType
9-
109
import numpy as np
1110
from rest_framework import status
1211
from rest_framework.decorators import action
@@ -536,7 +535,9 @@ def list(self, request, *args, **kwargs):
536535
# Check for LayerRepresentation if provided
537536
layer_representation = None
538537
if layer_type == 'raster' or layer_type == 'vector':
539-
layer_representation = LayerRepresentation.objects.filter(object_id=map_layer.id, map_type=ContentType.objects.get_for_model(map_layer))
538+
layer_representation = LayerRepresentation.objects.filter(
539+
object_id=map_layer.id, map_type=ContentType.objects.get_for_model(map_layer)
540+
)
540541

541542
if layer_representation and layer_representation.exists():
542543
layer_rep_obj = layer_representation.first()

uvdat/core/tasks/dataset.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,9 @@ def convert_dataset(
4747

4848
# Handle Vector files
4949
tags = file_metadata.get('tags', False)
50-
metadata_modified = {}
50+
metadata_modified = {}
5151
if tags:
52-
metadata_modified = { 'tags': tags }
52+
metadata_modified = {'tags': tags}
5353
vector_map_layers = create_vector_map_layer(
5454
file_to_convert,
5555
style_options=style_options,

uvdat/core/tasks/netcdf.py

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@
99
from PIL import Image
1010
from celery import current_task, shared_task
1111
import cftime
12-
from django.db import transaction
1312
from django.contrib.gis.geos import Polygon
1413
from django.contrib.gis.geos.error import GEOSException
1514
from django.core.files.base import ContentFile
15+
from django.db import transaction
1616
from matplotlib import cm
1717
import numpy as np
1818
import pandas as pd
@@ -175,7 +175,6 @@ def create_netcdf_data_layer(file_item, metadata):
175175
logger.warning(f'Variable Min/Max Exception {var_name}: {e}')
176176
logger.warning(f'Variable info {var_info}')
177177

178-
179178
description['variables'][var_name] = var_info
180179
if metadata.get('tags', False):
181180
description['tags'] = metadata.get('tags')
@@ -570,7 +569,9 @@ def create_netcdf_slices(
570569
and all(isinstance(x, int) for x in slicer_range)
571570
)
572571

573-
if is_range_of_integers and not (np.issubdtype(ds[sliding_variable].dtype, np.datetime64)):
572+
if is_range_of_integers and not (
573+
np.issubdtype(ds[sliding_variable].dtype, np.datetime64)
574+
):
574575
# Check if range is within the number of layers
575576
num_layers = len(ds[sliding_variable])
576577
if not (
@@ -780,14 +781,16 @@ def create_netcdf_slices(
780781
slice_data = data_var.isel(indexers).values
781782

782783
# Normalize data to 0-1 for colormap application
783-
# Uncomment for per-image normalization
784+
# Uncomment for per-image normalization
784785
# slice_min = np.nanmin(slice_data)
785786
# slice_max = np.nanmax(slice_data)
786787
normalized_data = (slice_data - slice_min) / (slice_max - slice_min)
787788

788789
# Apply the colormap
789790
colored_data = colormap(normalized_data) # Returns RGBA values
790-
colored_data = (colored_data[:, :, :3] * 255).astype(np.uint8) # Drop alpha, scale to 0-255
791+
colored_data = (colored_data[:, :, :3] * 255).astype(
792+
np.uint8
793+
) # Drop alpha, scale to 0-255
791794

792795
# Convert to an RGB image using PIL
793796
image = Image.fromarray(colored_data, mode='RGB')
@@ -798,15 +801,17 @@ def create_netcdf_slices(
798801
image_content = ContentFile(image_buffer.getvalue(), name=image_name)
799802

800803
# Collect the NetCDFImage objects for bulk creation later
801-
image_objects.append(NetCDFImage(
802-
netcdf_layer=netcdf_layer,
803-
image=image_content, # Save the image to the S3 field
804-
slider_index=i,
805-
bounds=bounds, # Reuse the bounds calculated earlier
806-
))
804+
image_objects.append(
805+
NetCDFImage(
806+
netcdf_layer=netcdf_layer,
807+
image=image_content, # Save the image to the S3 field
808+
slider_index=i,
809+
bounds=bounds, # Reuse the bounds calculated earlier
810+
)
811+
)
807812

808813
# Bulk create the NetCDFImage objects in a single database transaction
809-
logger.info(f'Creating Image Objects')
814+
logger.info('Creating Image Objects')
810815
with transaction.atomic():
811816
NetCDFImage.objects.bulk_create(image_objects)
812817
if processing_task:

0 commit comments

Comments
 (0)