Created
April 22, 2019 14:05
-
-
Save NimishMishra/b31e257dcc83c7cf9bb8b5eee577a601 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Loads the HDF file, gets the Longitude subdataset and returns the information of the nearest pixel to specified position | |
def find_longitude_position(CITY_LONGITUDE, LATITUDE_ROW_NUMBER, FILEPATH): | |
dataset_to_load = 'Longitude (32-bit floating-point)' | |
longitude_dataframe = read_dataset(dataset_to_load, FILEPATH) | |
min_diff = 100 | |
row_number = -1 | |
column_number = -1 | |
rows = longitude_dataframe.shape[0] | |
columns = longitude_dataframe.shape[1] | |
for j in range(columns): | |
lon = longitude_dataframe.iloc[LATITUDE_ROW_NUMBER][j] | |
diff = np.abs(lon - CITY_LONGITUDE) | |
if(diff < min_diff): | |
min_diff = diff | |
row_number = LATITUDE_ROW_NUMBER | |
column_number = j | |
found_lon = lon | |
if(column_number == -1): | |
print("Longitude not found. You might have chosen wrong scene") | |
return longitude_dataframe, column_number | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment