본문 바로가기

개발

python netCDF4 패키지 설치 설치 환경CetOS 7.x, Anaconda3설치 이유pip 에서 관리되는 netCDF4 의 whl 파일은 OS 에 따라 참조 라이브러리가 다름윈도우에서는 Anaconda3 의 라이브러리를 참조리눅스에서는 whl 파일에 라이브러리 포함해당 라이브러리는 HDF4 를 지원하지 않음 참고 링크http://unidata.github.io/netcdf4-python/https://pypi.org/project/netCDF4/https://github.com/Unidata/netcdf4-python netCDF4 패키지는 pip 모듈로 설치할 수 있으나, HDF4를 지원하지 않아 Anaconda3 의 라이브러리를 사용하도록 직접 설치(아래의 방법을 안쓰고 Anaconda3 의 conda-forge 채널을 이용해도 ..
Python ctypes 구조체 사용 Python 의 ctypes 에는 C 언어와 유사한 구조체 기능을 제공한다.(https://docs.python.org/2/library/ctypes.html#structured-data-types) 사용방법은 아래와 같다.12345678910111213import ctypes class my_struct(ctypes.Structure): _fields_ = [ ('data_1', ctypes.c_int), ('data_2', ctypes.c_int8), ('data_3', ctypes.c_uint8), ] print(ctypes.sizeof(my_struct))8 구조체 크기가 alignment 되는 것도 C 언어와 같다.C 에서는 #pragma pack(1) 또는 __attribute__((packe..
julian date 계산 1. datetime 이용123import datetime int(datetime.datetime(2018, 10, 4).strftime("%j")) 2. 직접 계산123456789101112def juldate(year, month, day): jmonth = [0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334] jday = jmonth[month - 1] + day if (year % 4 == 0 and year % 100 != 0) or year % 400 == 0: if month > 2: return jday + 1 return jday juldate(2018, 10, 4) 2.1. 검증123456789101112131415161718192021im..